Today, I needed to remove all the mail from every mailbox on an SBS 2008 Exchange server, mostly because I didn’t really like that the server sent a welcome email to each user giving them links to things we won’t be implementing. After a lot of Googling, I found the PowerShell command “Export-Mailbox” can do this for me. When I ran the command, I ran into some errors that weren’t very useful:
Command I ran: Get-Mailbox | Export-Mailbox -DeleteContent
StatusMessage : Error occurred in the step: Moving messages.
Failed to copy messages to the destination
mailbox store with error:
MAPI or an unspecified service provider.
ID no: 00000000-0000-00000000
ReportFile : C:Program FilesMicrosoftExchange ServerL
So after quite a while of more Googling, I found that this generic and almost useless error message is telling me that I don’t have permission to the mailbox in the first place, so I can’t delete any of the messages. Despite my being Administrator, here’s what I did to get past this issue altogether.
- Right click the Exchange Management Shell, and select Run as Administrator (this is a handy trick).
- Type the command “Get-Mailbox | Add-MailboxPermission -accessrights fullaccess -user Administrator” – if prompted, apply to ALL objects.
- Type the command “Get-Mailbox | Export-Mailbox -DeleteContent” – if prompted, apply to ALL objects.
- Type the command “Get-Mailbox | Remove-MailboxPermission -accessrights fullaccess -user Administrator” – Select “NO” when prompted about the Administrator mailbox! You can select “YES” for all other mailboxes, or apply to all if you want.