1
2
3
4
5
6
7
8
|
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文件
|
事例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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
|
本文转自bard_zhang51CTO博客,原文链接:http://blog.51cto.com/timefiles/1789432 ,如需转载请自行联系原作者