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.

posted @ 2012-07-24 13:36  Dance With Automation  Views(279)  Comments(0Edit  收藏  举报