Filtering Using WHERE

Welcome Forums General PowerShell Q&A Filtering Using WHERE

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
5 years ago.

  • Author
    Posts
  • #12850

    Participant
    Points: 0
    Rank: Member

    Hello: Using PS4. I have the following command and it works just fine. It filters out 'Symantec Antivirus' as expected.

    Get-EventLog -LogName Application -EntryType Error | sort Source | group Source | where Name -NE 'Symantec Antivirus'

    However, if I want to filter out nview in addition to 'Symantec Antivirus', it does not error out but then it displays 'Symantec Antivirus' and nview. It behaves as if there is no WHERE

    I'm trying to filter out entries I'm not interested in such as Symantec, etc.

  • #12852

    Member
    Points: 0
    Rank: Member

    You'll have to either go back to using Where-Object's older syntax (with a script block as the argument), or use the -NotIn operator instead of -ne:

    Where { $_.Name -ne 'Symantec Antivirus -and $_.Name -ne 'nview' }
    
    # or
    
    Where Name -NotIn 'Symantec Antivirus', 'nview'
    
  • #12853

    Participant
    Points: 0
    Rank: Member

    Thanks Dave. NotIn worked fine.

The topic ‘Filtering Using WHERE’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort