Solved

HELP! Exchange 2013 shell command to get both a count and then later copy specific emails from a particular user

Posted on 2014-11-10
5
36 Views
Last Modified: 2016-03-23
Shell is new to me and I recently downloaded Power-GUI. I am fairly good with MySQL(SQLYOG user) and MSSQL statements. I am also decent with Winbatch, But so far I am lost with powershell cmdlets. I need to do two things.

 I need to get total count of email in a users mailbox Lets say "John doe@mydomain.com" I need the count of all emails sent to and received from a clients domain such as wildcard@NotMyDomain.com" Something like

getemailcount WHERE mailboxnameis "John Doe" AND WHERE senderis LIKE "notmydomain.com" OR recipientis LIKE "notmydomain.com"

Then once I have the counts confirmed I would like to run a second script that does the same thing  as the first except each result is copied to another mailbox or a public folder.

I am pressed for time so figure I would ask here. Wish we could use the old system and award points as we see fit.
0
Comment
Question by:Cyprexx IT
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:yo_bee
ID: 40434231
0
 

Author Comment

by:Cyprexx IT
ID: 40435034
Thanks Yo Bee, I guess I should have mention that I had tried the same TechNet article you linked and a couple of  other forums examples, but it does not allow wildcards for the sender or recipient's email address.

I need the PowerSHELL equivalent of the SQL statements:

Select COUNT(*) from "Mail-BOX-NAME" where Sender.Email.Address LIKE "@domain_looking_for.com" or Reciepient.Email.Address LIKE "@domain_looking_for.com"

2nd Shell query:

Select INTO "NEW_MAIL_BOX_FOLDER" * from "Mail-BOX-NAME" where Sender.Email.Address LIKE "@domain_looking_for.com" or Reciepient.Email.Address LIKE "@domain_looking_for.com"

If I could get these into a Powershell or Power GUI I could stop stressing. LOL :)
0
 
LVL 21

Expert Comment

by:yo_bee
ID: 40435232
I do not think you can use the same SQL syntax when querying. Looks like it can be done with KQL http://msdn.microsoft.com/library/ee558911%28v=office.15%29.aspx .


I am only guessing here since I am not even on Exchange 2007 yet.
I do not know the -SearchQuery  fields that can be used, but here is an idea:

Search-Mailbox -Identity "John Doe" -SearchQuery 'From:*@notmydomain.com OR To:*@notmydomain.com'

Open in new window

See if the returns results and if so we can expand on it.
0
 

Author Comment

by:Cyprexx IT
ID: 40435745
This is where the problem began, it seems not to like the wild cards in the TO/FROM: . I even tried

Search-Mailbox -Identity "Jamey" -SearchQuery -LIKE 'From:*@fanniemae.com OR -LIKE To:*@fanniemae.com'.
0
 
LVL 21

Accepted Solution

by:
yo_bee earned 500 total points
ID: 40436120
do not use the word -LIKE
I think you maybe able to get away with *  
This is the same when trying to do a LDAP query.

What If you run it as I illustrated?
0

Featured Post

The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

Join & Write a Comment

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
The purpose of this video is to demonstrate how to use PicMonkey software to customize images for a Mailchimp campaign. Picmonkey is free and simple online software which can be used by users who don’t have robust editing software such as Photoshop,…
This Micro Tutorial will demonstrate the easy use of Gmail embedding images in your email so the recipient of your email can view them in context.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now