从 cygwin 窗口运行此命令失败,因为 powershell 找不到对象“Get-EventLog”:
echo "\n" | powershell.exe Get-EventLog System | Where-Object { $_.EventID -match "6009" }
Get-EveneLog Systerm 查询在 Powershell 控制台上工作得很好,所以我知道这不是语法问题。我已经包含了 powershell 路径。
有任何想法吗?
从 cygwin 窗口运行此命令失败,因为 powershell 找不到对象“Get-EventLog”:
echo "\n" | powershell.exe Get-EventLog System | Where-Object { $_.EventID -match "6009" }
Get-EveneLog Systerm 查询在 Powershell 控制台上工作得很好,所以我知道这不是语法问题。我已经包含了 powershell 路径。
有任何想法吗?
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" }'
powershell.exe -command '获取事件日志系统 | Where-Object { $_.EventID -match "6009" }'