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}
Mark is an Independent Microsoft Teams Consultant with over 15 years experience in Microsoft Technology. Mark is the founder of Commsverse, a dedicated Microsoft Teams conference and former MVP. You can follow him on twitter @UnifiedVale