Delete All Mails in Exchange2010 SP1

I have a powershell script to delete all mails in all database.
here is the script :
Get-MailboxDatabase|Set-MailboxDatabase -MailboxRetention 00.00:00:00
Get-MailboxDatabase|Clean-MailboxDatabase
Get-Mailbox -ResultSize unlimited|Search-Mailbox  -DeleteContent -Force

the Search-Mailbox is new comdlet only support 2010 sp1+, so NEED add the role, but in one of my environments, the script failed with error:
the target mailbox or .pst file path is required

solution:

if you want to use –DeleteContent parameter, you need to have “Mailbox Import Export” PERMISSIONS.

so after add the permission, the script works.

原文地址:https://www.cnblogs.com/dancewithautomation/p/2606349.html