Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 使用group by在WinRM上查询Win32\u NtLogEvent_Powershell_Wmi Query_Wql_Winrm - Fatal编程技术网

Powershell 使用group by在WinRM上查询Win32\u NtLogEvent

Powershell 使用group by在WinRM上查询Win32\u NtLogEvent,powershell,wmi-query,wql,winrm,Powershell,Wmi Query,Wql,Winrm,我需要一个从Win32\u NTLogEvent返回SourceName、Logfile、EventIdentifier、Type、NumberOfEvents的查询,其中NumberOfEvents是共享公共SourceName、Logfile和EventIdentifier的事件数(我不确定类型)。我想使用Get-CimInstance在PowerShell脚本中使用查询 对于可以在PowerShell中使用的相同问题的其他解决方案,我们也非常感谢 尝试以下操作: $Logs = Get-W

我需要一个从Win32\u NTLogEvent返回SourceName、Logfile、EventIdentifier、Type、NumberOfEvents的查询,其中NumberOfEvents是共享公共SourceName、Logfile和EventIdentifier的事件数(我不确定类型)。我想使用Get-CimInstance在PowerShell脚本中使用查询

对于可以在PowerShell中使用的相同问题的其他解决方案,我们也非常感谢

尝试以下操作:

$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

感谢您的回答,但使用查询的目的是服务器完成任务。在我的Windows上有超过10万个事件,因此这是有意义的。可能我还没有明确说明这个实例使用的是远程服务器。