1

I can't seem to figure out why this where object filter is not working. here is the code:

Get-MailDetailTransportRuleReport -StartDate 08/25/2022 -EndDate 09/07/2022 
| Where-Object -Property SenderAddress -NotContains "@EMAIL-DOMAIN-HERE" 
| fl Date, Subject, Direction, SenderAddress, RecipientAddress, TransportRule

and I am of course, getting all of the results with the "@EMAIL-DOMAIN-HERE" still in it.

Wise
  • 69
  • 7

1 Answers1

4

-notcontains is a collection containment operator, not a string comparison operator.

Use -notlike instead and make sure you include appropriate wildcards:

| Where-Object -Property SenderAddress -NotLike "*@EMAIL-DOMAIN-HERE" 
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206