1

从 cygwin 窗口运行此命令失败,因为 powershell 找不到对象“Get-EventLog”:

 echo "\n" | powershell.exe Get-EventLog System | Where-Object { $_.EventID -match "6009" }

Get-EveneLog Systerm 查询在 Powershell 控制台上工作得很好,所以我知道这不是语法问题。我已经包含了 powershell 路径。

有任何想法吗?

4

2 回答 2

2

After a brief trial and error session I discovered that if the query is encased in single quotes it will work :

powershell.exe 'Get-EventLog System | Where-Object { $_.EventID -match "6009" }'
于 2012-12-26T18:47:28.840 回答
0

powershell.exe -command '获取事件日志系统 | Where-Object { $_.EventID -match "6009" }'

于 2015-11-08T22:05:25.170 回答