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:
To verify that only the disconnected mailboxes will be removed, you run the following command
This will list all current disconnected mailboxes.
This command first retrieves all disconnected mailboxes from your server\database, and then runs the Remove-mailbox command for every mailbox.
To delete (purge) the disconnect mailboxes from a database, you run the following command from your Exchange Management Shell:
To verify that only the disconnected mailboxes will be removed, you run the following command
This will list all current disconnected mailboxes.
Code:
Get-MailboxStatistics -database "server\database" | where {$_.disconnectdate -ne $null}
Code:
Get-MailboxStatistics -database "server\database" | where {$_.disconnectdate -ne $null} | foreach {Remove-mailbox -database $_.database -storemailboxidentity $_.mailboxguid}