使用PowerShell事件日志和导出过滤器,以CSV
问题描述:
我有以下命令,给我需要的信息,但我需要过滤它远一点:使用PowerShell事件日志和导出过滤器,以CSV
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...}
我想删除ReplacementStrings与开头的条目“{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