Insights Removing Ghost Mailboxes from Exchange with Remove-Mailbox and -StoreMailbox

Removing Ghost Mailboxes from Exchange with Remove-Mailbox and -StoreMailbox

I ran into an absolutely crazy issue which involved Exchange 2010 and a group of “ghost” mailboxes.  The specifics were that the mailboxes showed up in Get-MailboxStatistics reports on the databases, but were not connected, “Deleted”, or “Soft Deleted”.  They were not visible in the console, or during a Get-Mailbox command, through either their GUID or the user name.  I believe they are the result of failed mailbox moves, but I can’t be certain.  That said, the goal was to delete them, but how?   To find the mailboxes, we used the following command:   Get-MailboxStatistics -Server MBX | Select displayname, MailboxGUID, Mailbox, DatabaseName, ItemCount, TotalItemSize, LastLoggedOnUserAccount   To dump it to CSV we used this command:   Get-MailboxStatistics -Server MBX | Select displayname, MailboxGUID, Mailbox, DatabaseName, ItemCount, TotalItemSize, LastLoggedOnUserAccount | Export-CSV dump.csv   To find an individual mailbox that is in this state based on its GUID we used (where GUID is that of the mailbox from the report):   Get-MailboxStatistics -Server MBX | Select displayname, MailboxGUID, Mailbox, DatabaseName | Where-Object { $_.MailboxGUID -eq “67879cee-65314586-85e4-76895edcedb4”} 

We now know the individual mailboxes we want, and we were able to individually reference the mailbox by its GUID.  Now to delete it!!Get-Mailbox and Remove-Mailbox didn’t work…   The Get-Mailbox and Remove-Mailbox commands with “–Identity” both were unable to find the mailbox based on the user’s name and the user’s identity because the “object could not be found on [ServerName]”.   Remove-StoreMailbox also didn’t work…   The Remove-StorageMailbox command didn’t believe the mailbox to actually be disconnected or soft deleted.  It indicated “The mailbox [GUID] isn’t disconnected”   Clean-MailboxDatabase ran, but didn’t remove the mailbox, or make it show up as disconnected.  I believe this is because the mailbox was ultimately not actually disconnected or soft deleted.   Finally, we found the little used switch of Remove-Mailbox (-StoreMailboxIdentity).   To remove the mailbox we did this:   Remove-Mailbox -Database MBX -StoreMailboxIdentity 67879cee-6531-4586-85e4-76895edcedb4   I hope this helps you clean the ghosts from your Exchange environment.  Now… to write an Orchestrator runbook to do this automatically…  

Cheers,  

Nathan Lasnoski