Use -notlike to filter out multiple strings in PowerShell

后端 未结 9 511
执念已碎
执念已碎 2020-12-14 15:58

I\'m trying to read the event log for a security audit for all users except two, but is it possible to do that with the -notlike operator?

It\'s somethi

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 16:25

    Easiest way I find for multiple searches is to pipe them all (probably heavier CPU use) but for your example user:

    Get-EventLog -LogName Security | where {$_.UserName -notlike "*user1"} |  where {$_.UserName -notlike "*user2"}
    

提交回复
热议问题