我需要一个从Win32_NTLogEvent返回SourceName,Logfile,EventIdentifier,Type,NumberOfEvents的查询,其中NumberOfEvents是共享公共SourceName,LogFile和EventIdentifier的事件数(我不确定Type)。我想使用Get-CimInstance在PowerShell脚本中使用该查询。
对PowerShell中可以使用的同一问题的其他解决方案也非常感谢!
答案 0 :(得分:0)
请尝试以下操作:
$Logs = Get-WmiObject -class Win32_NTLogEvent -filter "(logfile='Application')"
Write-Host $logs
当然,过滤你可以改变。如果您更喜欢结果的其他“格式”,您可以使用例如:
$Logs | Format-Table EventCode, EventType, Message -auto
<强>更新强> 我刚刚再次阅读你的问题:)要进行分组只需调用:
$logs | Group-Object Type,LogFile,EventCode