Remove disconnected Mailboxes on Exchange 2007

In Exchange 2007 you can’t remove disconnected mailboxes from the GUI you can do this from the powershell.

Show the disconnected mailboxes on the server.

Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid

Remove one disconnected mailbox.

Remove-Mailbox -Database -StoreMailboxIdentity -confirm:$false

To remove all mailboxes at ones we have to set a variable then give the command to cleanup disconnected mailboxes.

$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid

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

To remove all disconnected mailboxes on a server in every datastore use the following command.

$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database$users | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }