Use -notlike to filter out multiple strings in PowerShell

后端 未结 9 508
执念已碎
执念已碎 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:24

    I think Peter has the right idea. I would use a regular expression for this along with the -notmatch operator.

    Get-EventLog Security | ?{$_.Username -notmatch '^user1$|^.*user$'}
    

提交回复
热议问题