We help IT Professionals succeed at work.

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

185 Views
Last Modified: 2019-01-10
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

FOXActive Directory/Exchange Engineer
CERTIFIED EXPERT
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
CERTIFIED EXPERT
Top Expert 2015
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.