cd D:\2016-06-13 #进入所要遍历额文件目录 Select-String ` "Files Excluded","Files Scanned","Directories Scanned", ` "Directories Excluded","Files Skipped","Files Scan Error", ` "Files Infected","Total Bytes" ` #所要筛选的关键词,多个用逗号隔开 -Encoding oem` #指定编码格式,如果不指定可能会造成中文乱码 *.log ` #在当前目录下所以log文件中查找 | Out-File -Width 800 qq.csv #防止内容显示不全修改显示宽带为800,输出到当前目录下qq.csv文件
事例:
cd D:\2016-06-13 Select-String ` "Files Excluded","Files Scanned","Directories Scanned", ` "Directories Excluded","Files Skipped","Files Scan Error", ` "Files Infected","Total Bytes" ` -Encoding oem *.log ` | Out-File qq.csv cd D:\2016-06-13\z Select-String ` "Files Excluded","Files Scanned","Directories Scanned", ` "Directories Excluded","Files Skipped","Files Scan Error", ` "Files Infected","Total Bytes" ` -Encoding oem *.log ` | Out-File qq.csv cd D:\2016-06-13 Select-String ` "Infected" ` -Encoding oem *.log ` | Format-Table -Property line ` | Out-File infected.csv cd D:\2016-06-13\z Select-String ` "Infected" ` -Encoding oem *.log ` | Format-Table -Property line ` | Out-File infected.csv