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}

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.