Remove Soft Deleted Mailboxes from Exchange Database

When moving mailboxes between databases you sometimes experience the moves completing with a warning. The warning may be that post move cleanup could not be completed on the source mailbox database. This means that you will see disconnected mailboxes in EMC even though the users mailbox is live on the other database. In this circumstance you need to remove the disconnected or soft deleted mailboxes from the old database to free up space.

You can do this by first obtaining the mailbox GUID of the soft deleted mailbox using this command

Get-MailboxStatistics -Database <dbname> | Where {$._DisconnectREason -eq "SoftDeleted"} | fl MailboxGuid

Then you can use the output of this to then remove the mailbox using this command

Remove-StoreMailbox -Database <dbname> -Identity <mailboxguid> -MailboxState SoftDeleted -Confirm:$false

To remove all soft deleted mailboxes from a database in one go you can use this command

Get-MailboxStatistics -Database MBD01 | where {$_.DisconnectReason -eq "SoftDeleted"} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s