Powershell exchange get-mail with specific subject wildcard use for specific recipient.

dee30
dee30 used Ask the Experts™
on
Hello,

Looking for help in searching for email via PS based on specific criteria and/or range.

Date range from to to
recipient : address known
subject: wild card use to match "*fishing*" or "*water team*"

Get-messagetrackinglog -ResultSize Unlimited -Start "12-16-2018 7:00:00AM" -End "12-18-2018 10:30AM"  -recipients:jdoe@domain.com | where{$_MessageSubject -like "*fishing*"| select-object Timestamp,sourcecontext,source,eventID,MessageSubject,Sender,{$_.Recipients} | format-table  

Above doesn't work for just one subject wildcard, while I haven't even gotten to include the 'or' other criteria yet.

Some assistance on syntax would be truly be appreciated.  Note on premise 2010 Exchange. Thank you.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
FOXActive Directory/Exchange Engineer
Top Expert 2015

Commented:
What exactly is the error it is throwing and it looks like you are missing a . in front of MessageSubject  - try this:  

Get-messagetrackinglog -ResultSize Unlimited -Start "12-16-2018 7:00:00AM" -End "12-18-2018 10:30AM"  -recipients:jdoe@domain.com | where{$_.MessageSubject -like "*fishing*"| select-object Timestamp,sourcecontext,source,eventID,MessageSubject,Sender,{$_.Recipients} | format-table

Author

Commented:
I got it to work... was missing the period(.) like you pointed out in front of where-objects listed, as well as a closing curly bracket/brace after *fishing*"}   .

So, that all said how would update the syntax to include an 'or' , i.e., subject line to include the word *fishing* OR *net* ?

Thank you.
Active Directory/Exchange Engineer
Top Expert 2015
Commented:
Try the below:

Get-messagetrackinglog -ResultSize Unlimited -Start "12-16-2018 7:00:00AM" -End "12-18-2018 10:30AM"  -recipients:jdoe@domain.com | where{$_.MessageSubject -like "*fishing*" -and "*net*"} | select-object Timestamp,sourcecontext,source,eventID,MessageSubject,Sender,{$_.Recipients} | format-table

Author

Commented:
Thanks.. assigning points.  Will try that next time.. Done with Exchange for today and moving on to some vmware issues.  Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial