我有以下命令可以提供我需要的信息,但我需要进一步过滤它:
Get-EventLog -LogName Security -ErrorAction SilentlyContinue | Select TimeWritten, ReplacementStrings | Export-Csv output.csv
这给出了许多条目,例如:
09/11/2012 08:09:27 {S-1-5-18, SYSTEM, NT AUTHORITY, 0x3e7...}
我想删除替换字符串中以"{S-1-5"开头的任何条目,但我尝试使用Where-Object
和-notlike
没有任何区别!
我遇到的另一个问题是,如果没有添加Export-Csv output.csv
,它可以正常显示在屏幕上,但它会像这样写入文件:
"09/11/2012 09:22:05","System.String[]"
Get-EventLog -LogName Security -ErrorAction SilentlyContinue |
Select TimeWritten, @{name='ReplacementStrings';Expression={ $_.ReplacementStrings -join ';'}} |
where {$_.ReplacementStrings -notmatch '^S-1-5'} | Export-Csv output.csv