How to search all mailboxes Exchange 2013 for email address

I need to search all mailboxes to see if someone has sent or received an email from a particular external email address.
I tried this, but it didn't work:

Get-Mailbox | Search-Mailbox -SearchQuery 'emailaddress@google.com' -TargetMailbox "testmailbox" -TargetFolder "test" -LogLevel Full
cwhitmore88Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peter HutchisonSenior Network Systems SpecialistCommented:
Try searching the Message Tracking logs, which record all incoming or outgoing messages,  instead e.g.

Get-MessageTrackingLog -Recipients emailaddress@google.com

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AmitIT ArchitectCommented:
Run like this:

Get-mailboxserver -identity servername | search-mailbox -searchquery "from:sender@domain.com" -targetmailbox testmailbox -TargetFolder "test" -loglevel full
Will SzymkowskiSenior Solution ArchitectCommented:
Message Tracking would be the most accurate way to track this down. If you use Search Mailbox this only searches the items that are actually in the mailbox itself. If the items do not exist due to deleted by the user or a rule then you results will come back with nothing. Message tracking will show all users that received the email regardless if it is still in their mailbox.

So Peter's command should suffice.

Will.
AmitIT ArchitectCommented:
I agree to Will. Also, if you still want to use that command. Pipe this
get-mailbox -server exchangeservername -resultsize unlimited
Minecraft_ EndermanCommented:
Search all messages sent to a particular external email address

Get-Mailbox | Search-Mailbox –SearchQuery “To:emailaddress@google.com” -TargetMailbox "testmailbox" -TargetFolder "test" -LogLevel Full

Search all messages received from a particular external email address

Get-Mailbox | Search-Mailbox –SearchQuery “From:emailaddress@google.com” -TargetMailbox "testmailbox" -TargetFolder "test" -LogLevel Full

Advanced Query Syntax in exchange search:
https://technet.microsoft.com/en-us/library/bb232132(v=exchg.141).aspx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.