Exchange server 2013 Search-Mailbox for criteria BODY in remote powershell

2.3k Views Asked by At

I am trying to search emails that contains some string in their body. I have two email which contains the work booze.

The command I am using to search is

Get-Mailbox | Search-Mailbox -SearchQuery "Body:'booze'" -WarningAction:SilentlyContinue -EstimateResultOnly -SearchDumpster:$false

but this command is returning 0. What is wrong with this command?

I run a similar command for subject which works

Get-Mailbox | Search-Mailbox -SearchQuery "Subject:'test'" -WarningAction:SilentlyContinue -EstimateResultOnly -SearchDumpster:$false
2

There are 2 best solutions below

0
On

You don't need to add the Body: section. Try this (untested):

Get-Mailbox | Search-Mailbox -SearchQuery 'booze' -WarningAction:SilentlyContinue -EstimateResultOnly -SearchDumpster:$false

https://technet.microsoft.com/en-us/library/dd298173(v=exchg.160).aspx

0
On

I just ran this on my Exchange 2016 box on some random user and it returned over 13,000 results:

Search-Mailbox RANDOMUSER -SearchQuery "Body:'it'" -EstimateResultOnly

And this returned an insane amount of results on pretty much every mailbox:

Get-Mailbox | Search-Mailbox -SearchQuery "Body:'it'" -WarningAction:SilentlyContinue -EstimateResultOnly -SearchDumpster:$false