When you have deleted an mail-enabled Active Directory account, the mailbox will be moved to Disconnected Mailbox in your Exchange Management Console.
To delete (purge)Â the disconnect mailboxes from a database, you run the following command from your Exchange Management Shell:
Get-MailboxStatistics -database "server\database" | where {$_.disconnectdate -ne $null} | foreach {Remove-mailbox -database $_.database -storemailboxidentity $_.mailboxguid}
This command first retrieves all disconnected mailboxes from your server\database, and then runs the Remove-mailbox command for every mailbox. To verify that only the disconnected mailboxes will be removed, you run the following command first:
Get-MailboxStatistics -database "server\database" | where {$_.disconnectdate -ne $null}
This will list all current disconnected mailboxes.
Thanks a lot for the shell command. It helped to delete a user mailbox in Disconnected mailbox in my lab Exchange 2007 server. Note- When running this command ensure the “server\database” is replaced by the Exchange server name and the Mailbox database name. For ex- “exch1\First Storage Group\Mailbox database”
This command worked exactly as written. Thank you.
Thank you for the command !!!!!!!!!!!!!!!
Thank you. I have a question thou. There are still some mailboxes that will not delete. We had some issues with exchange and moved these mailboxes to another database and now the old mailbox shows as disconnected but will not delete since that user name is still active. So my question is “How do you remove those mailboxes?”.
Thank you
Hi Michelle,
when the user is still active, you could try to connect the mailbox to the user who it belongs to.
You can do this with the Exchange Management Console, or with the Management Shell:
—
Connect-Mailbox -Identity “John Brown” -Database “Mailbox Database” -User “John Brown”
—
After you connect the mailbox to the user, you can remove the Exchange attributes, again with the Management Console or the Management Shell.
Excelent! Thanks!
Thanks this worked great!!
What a convoluted mess. Why there is no right click command on the Exchange console is beyond me… Just like removing ExMerge capabilities…
I tried… I keep getting an error!
can someone tell me “EXACTLY” what to type?
address is – jpatrick@xyz.com
server is – abc.int
Thank you very useful 🙂
Hi Michelle,
when the user is still active, you could try to connect the mailbox to the user who it belongs to.
You can do this with the Exchange Management Console, or with the Management Shell:
—
Connect-Mailbox -Identity “John Brown” -Database “Mailbox Database” -User “John Brown”
—
After you connect the mailbox to the user, you can remove the Exchange attributes, again with the Management Console or the Management Shell.