0

I am using this PowerShell command to try and delete emails from our Exchange Journal,

[PS] C:\Windows\system32>Search-Mailbox -Identity exchangejournal -SearchQuery "Received:12/31/2012..06/30/2013" -DeleteContent

It says it is successful, but it shows ResultItemsCount: 0 and ResultItemsSize: 0 B <0 bytes>. But if I log into that mailbox there are emails from that date. Any suggestions as to what I may be doing wrong?

Thanks

  • 1
    I'll offer a complete guess - check your date format. – Sobrique Aug 19 '14 at 13:34
1

There are several possible caveats here.

Enclose the Keyword Query in curly brackets:

Search-Mailbox -Identity exchangejournal -SearchQuery {received:12/31/2012..06/30/2013}

Make sure your dates matches the ShortDate format on your computer. For example on my machine with Danish locale setting it would be: {received:31-12-2012..30-06-20}. An easy experiment to determine yours would be:

(Get-Date).ToShortDateString()

I've seen problems querying the Received property in the past. If none of the above helps, you might want to try with the Sent property instead:

Search-Mailbox -Identity exchangejournal -SearchQuery {sent:12/31/2012..06/30/2013}

If you get any syntax errors regarding the dates after removing the quotations marks, enclose the date range in parentheses: {sent:(12/31/2012..06/30/2013)}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.