We help IT Professionals succeed at work.

Exchange 2010 remove disconnected mailbox error - doesn't exist on database "mailbox"

ajdratch asked
I moved a client from Exchange 2010 to Office 365. Now that the migration is done, I want to remove Exchange.  All the mailboxes are disconnected however I can't remove them. I ran the commands:
$mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database

$mailboxes | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }

I then get this message for every disconnected mailbox

Mailbox "31ea850d-6a5d-4286-9441-d5baf6c7c4ef" doesn't exist on database "Mailbox".
    + CategoryInfo          : NotSpecified: (0:Int32) [Remove-Mailbox], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : DFBA03DE,Microsoft.Exchange.Management.RecipientTasks.RemoveMailbox

I stopped the sync this morning by running Set-MsolDirSyncEnabled -EnableDirSync $false.

How can I remove these disconnected mailboxes
Watch Question

Paul MacDonaldDirector, Information Systems

Is there more than one mailbox database?  

Or (maybe more likely) is this an old AD object that existed in a mailbox database prior to Exchange 2010?  The AD object may still exist, but the mailbox database it refers to no longer exists.  As it is, it's only passing back the GUID for the object.  It's entirely possible these items that won't remove themselves can't because they never existed in Exchange 2010.


These are all the mailboxes that that were migrated to Office 365 so they did exist in Exchange 2010
I found the solution here https://expert-advice.org/exchange-server/remove-disconnectedsoft-deleted-mailboxes-exchange-20102013-database/

To remove the Soft-Deleted mailboxes in database:

$Mailboxes = Get-MailboxStatistics -Database “MailboxDatabase″ | where {$_.DisconnectReason -eq “SoftDeleted”}

$Mailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted -Confirm:$False}