Powershell EWS Nested search filter

649 views Asked by At

I'm trying to perform a search filter using EWS on a function based on Powershell. I would like to mix AND & OR due i mix different properties, i've tried the method below but it didn't work as expected:

                    $sfCollectionAND = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+SearchFilterCollection([Microsoft.Exchange.WebServices.Data.LogicalOperator]::And)
                    $sfCollectionAND .add($SenderAddress1)
                    $sfCollectionAND .add($SenderAddress2)

$sfCollectionOR = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+SearchFilterCollection([Microsoft.Exchange.WebServices.Data.LogicalOperator]::Or)
                    $sfCollectionOR .add($sfCollectionAND)
                    $sfCollectionOR .add($ReceiveDate1)
                    $sfCollectionOR .add($ReceiveDate2)

Basically the filter purpose is 1st gather message between period of time and then exclude 2 senders.

0

There are 0 answers