I have an administrator mailbox on my Exchange server where spam goes, so it's loaded with mail and I want to bulk delete alot of it. I had the powershell command once and it worked but I lost it.
I tried this
search-mailbox -Identity administrator -SearchQuery "Received:> $('1/01/2012') and Received:< $('1/31/2012')" -DeleteContent
and it seems like it worked, I got a ResultItemsCount : 2448 ResultItemsSize : 111.4 MB (116,811,965 bytes)
Yet email from January 2012 is still in the inbox.
I also tried replacing search-mailbox with get-mailbox
get-mailbox -Identity administrator -SearchQuery "Received:> $('1/01/2012') and Received:< $('1/31/2012')" -DeleteContent
This caused an error - A positional parameter cannot be found that accepts argument '-SearchQuery'. blah blah blah
Any ideas? Thanks a lot.