Exchange 2010 SP1 server. I am trying to search for all messages in a given date range and delete the content from the mailbox. The script I am using returns the messages I am searching for, but when the -deletecontent switch is introduced, the data is not deleted and no errors are generated. I am returned with an empty data set. The line of code to delete all mail from 2009 is:
search-mailbox $mailboxuser -SearchQuery "Received:> $('1/01/2009') and Received:< $('12/31/2009')" -DeleteContent
However, if I introduce the -LogOnly switch, the dataset I am looking to delete is properly returned:
search-mailbox $mailboxuser -SearchQuery "Received:> $('1/01/2009') and Received:< $('12/31/2009')" -TargetMailbox $testmailbox -TargetFolder "Discovery" -Loglevel Full –LogOnly
I have verified that the single item recovery for the user's mailbox is set to False and that the user running the script is a member of the Import Export group. I had a script that was working perfectly in 2010 Exchange pre sp1 to export and delete content, but now I can only get the export to work with the New-MailboxExportRequest. The delete content command should work with the search-mailbox funciton, but something is being overlooked or is broken. Anyone out there successfully do what I am trying? I don't feel like this task is one that should be too uncommon. Not that it is relevant for SP1, but I am running this code on a server that only has the Mailbox role.