Link to home
Start Free TrialLog in
Avatar of Cyprexx IT
Cyprexx IT

asked on

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

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

Avatar of Cyprexx IT
Cyprexx IT

ASKER

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 :)
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.
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'.
ASKER CERTIFIED SOLUTION
Avatar of yo_bee
yo_bee
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