Link to home
Start Free TrialLog in
Avatar of dee30
dee30Flag for United States of America

asked on

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

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.
Avatar of FOX
FOX
Flag of United States of America image

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
Avatar of dee30

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of FOX
FOX
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dee30

ASKER

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