Filter command not working RRS feed

  • Question

  • Hi Im trying to return some Exchange tracking logs - minus a few connector IDs.  I've added a filter as below but its completely ignored.  Any idea why?

    Get-MessageTrackingLog -Start (Get-Date).AddHours(-24) -ResultSize unlimited | Select-Object eventid,messageid,sender,ReturnPath,timestamp,connectorid,@{Name="ClientIp";Expression={$_.ClientIp}},@{Name="Recipients";Expression={$_.recipients}},@{Name="RecipientStatus";Expression={$_.recipientstatus}},messagesubject | where {($_.ConnectorId -notlike "" -or $_.ConnectorId -notlike "SMTP Send Connector") -and ($_.ConnectorId -notlike "servercd201" -or $_.ConnectorId -notlike "serverd101") -and ($_.ConnectorId -notlike "Websense Send" -or $_.ConnectorId -notlike "Websense")} | sort connectorid | Export-csv c:\temp\ConnectorStats.csv -nti

    • Moved by Bill_Stewart Wednesday, September 4, 2019 6:06 PM Abandoned
    Wednesday, February 13, 2019 11:00 AM

All replies

  • The -Like and -NotLike operators require the "*" wildcard. If you want to not include cases where ConnectorId is blank (or not set), then you want:

    ($_.ConnectorId -Like "*")

    That clause only includes cases where there is a ConnectorId, and it would be And'ed with other clauses.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, February 13, 2019 1:42 PM
  • Thanks Slava I just tried this but get exactly the same result, nothing is filtered?
    Thursday, February 14, 2019 4:49 PM