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
52 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

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 23

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 23

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 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