If you have Exchange Server 2007 SP1, you can use the Export-Mailbox
cmdlet, with the -DeleteContent
flag and without a target, to simply delete to email items that otherwise would have been exported:
Get-Mailbox | Export-Mailbox -EndDate (Get-Date).AddDays(-90) -DeleteContent
In the example, all items in all folders, from before 90 days ago, will be deleted. You'll need to have FullAccess rights on each mailbox you perform this operation on.
To exclude certain folders, like Contacts or Calendar, use the -ExcludeFolders
flag, like this:
Export-Mailbox -ExcludeFolders "\Contacts","\Calendar" -DeleteContent
I asked Microsoft support, and they told me this can not only be done, but it can even be done by the customer, without requiring any support call.
The global configuration for the deleted items retention period is stored in the Mailbox Plans assigned to users:
PS C:\windows\system32> Get-MailboxPlan | ft Name, RetainDeletedItemsFor
Name RetainDeletedItemsFor
---- ---------------------
ExchangeOnlineDeskless-200f67ad-971f-4485-8df4-496cb337aaa0 14.00:00:00
ExchangeOnlineEnterprise-7d4dfcb8-b74f-4fbc-b154-008eba3ed7ab 14.00:00:00
ExchangeOnline-6562c5b9-cec6-4d6c-bbed-5cd1551877c7 14.00:00:00
In order to configure it, you can use the Set-MailboxPlan
cmdlet:
Get-MailboxPlan | Set-MailboxPlan -RetainDeletedItemsFor "30.00:00:00"
After doing this, the global settings will be changed:
PS C:\windows\system32> Get-MailboxPlan | ft Name, RetainDeletedItemsFor
Name RetainDeletedItemsFor
---- ---------------------
ExchangeOnlineDeskless-200f67ad-971f-4485-8df4-496cb337aaa0 30.00:00:00
ExchangeOnlineEnterprise-7d4dfcb8-b74f-4fbc-b154-008eba3ed7ab 30.00:00:00
ExchangeOnline-6562c5b9-cec6-4d6c-bbed-5cd1551877c7 30.00:00:00
This will apply the settings to all new users; however, you'll still need to modify it for existing users:
Get-Mailbox | Set-Mailbox -RetainDeletedItemsFor "30.00:00:00"
Best Answer
Use the
Search-Mailbox
cmdlet to search for items deleted today, and copy them back.NOTE: I haven't tested this yet, so please follow all three steps and make sure it acts as expected!
Perform a search on a Test Mailbox and review the output:
Perform a search again on a Test Mailbox and verify that messages deleted today were moved back
Perform the search on all mailboxes and emjoy!
I hope this helps :-)