Select Get-WmiObject Powershell 查询的前 5 个或限制为 5 个条目
Select Top 5 or Limit to 5 entries on Get-WmiObject Powershell query
我正在事件查看器上执行查询 (Win32_NTLogEvent)
无论如何只有 select 前 10 名或最多 5 return 事件
我已经尝试过 TOP
、LIMIT
或 ROWCOUNT
,但没有任何效果
Get-WmiObject -Query 'SELECT * FROM Win32_NTLogEvent WHERE (SourceName = "Microsoft-Windows-Kernel-Power" and EventCode = "41")'
WQL doesn't support the TOP
, LIMIT
or ROWCOUNT
keywords; instead, you'll need to pipe the results to the Select-Object
cmdlet 和 select -First 10
行,例如:
Get-WmiObject -Query 'SELECT * FROM Win32_NTLogEvent WHERE (SourceName = "Microsoft-Windows-Kernel-Power" and EventCode = "41")' | select -First 10
您可能还需要先通过 Sort-Object
cmdlet 传输结果,以便结果按给定的 属性 在 selection 之前排序。
我正在事件查看器上执行查询 (Win32_NTLogEvent)
无论如何只有 select 前 10 名或最多 5 return 事件
我已经尝试过 TOP
、LIMIT
或 ROWCOUNT
,但没有任何效果
Get-WmiObject -Query 'SELECT * FROM Win32_NTLogEvent WHERE (SourceName = "Microsoft-Windows-Kernel-Power" and EventCode = "41")'
WQL doesn't support the TOP
, LIMIT
or ROWCOUNT
keywords; instead, you'll need to pipe the results to the Select-Object
cmdlet 和 select -First 10
行,例如:
Get-WmiObject -Query 'SELECT * FROM Win32_NTLogEvent WHERE (SourceName = "Microsoft-Windows-Kernel-Power" and EventCode = "41")' | select -First 10
您可能还需要先通过 Sort-Object
cmdlet 传输结果,以便结果按给定的 属性 在 selection 之前排序。