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
48 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 22

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 22

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 22

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Pop culture is prime bait for hackers seeking to infect user’s computers and mobile devices with malicious malware. Hackers know exactly what the latest trends are online and know how to use them to their advantage.
As cyber crime continues to grow in both numbers and sophistication, a troubling trend of optimization has emerged over the last year.
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

807 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