0

我遇到了这个Get-WinEvent 仅获取交互式登录消息并尝试OR在相同的情况下玩弄:

 Get-WinEvent -FilterHashtable @{Path="c:\test.evtx"; id=4624;} | Where-Object {$_.properties[8].value -eq 2} OR {$_.properties[8].value -eq 3}

我想知道这不起作用吗?

如果我有两个不同的 eventid 和两个不同的 where 子句,例如4624EventId 和 logontype2或 logontype 3
OR eventid1234和 hostname =会发生什么localhost

我需要做的是仅检查 logontype:2 和 logontype 3 并在 logontype 为 3(远程)时打印 Network-Details。

4

1 回答 1

1

OR在 PowerShell 中无效...您可能的意思是-or

在这种情况下,您的代码最终看起来像这样:

Get-WinEvent -FilterHashtable @{Path="c:\test.evtx"; id=4624;} |
    Where-Object {$_.properties[8].value -eq 2 -OR $_.properties[8].value -eq 3}

另外,-in在这种情况下,我经常发现操作符更清晰

Get-WinEvent -FilterHashtable @{Path="c:\test.evtx"; id=4624;} |
    Where-Object {$_.properties[8].value -in 2, 3}
于 2018-01-29T08:46:33.667 回答