19
Aug 2009

Empty All Exchange 2007 Mailboxes

comment icon2 comment(s) |

The Problem

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

Error:

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 Files\Microsoft\Exchange Server\L
ogging\MigrationLogs\export-Mailbox20090819-
104007-5727927.xml

The Solution

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.

 

  1. Right click the Exchange Management Shell, and select Run as Administrator (this is a handy trick).
  2. Type the command "Get-Mailbox | Add-MailboxPermission -accessrights fullaccess -user Administrator" - if prompted, apply to ALL objects.
  3. Type the command "Get-Mailbox | Export-Mailbox -DeleteContent" - if prompted, apply to ALL objects.
  4. 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.
Hope this helps, and I hope it helps you delete all mail from mailboxes in Exchange 2007, just like it did for me!

 

Comments

Nice thread Brad. This indeed

Nice thread Brad. This indeed looks like it would have been a fun Google search experience.

Helpful

Just came across this while attempting my own Googling .. very helpful and worked perfect

thanks!