Remove all disconnected mailboxes Exchange 2007

Reading Time: < 1 minute

To remove all disconnected Exchange 2007 mailboxes one by one or the option to remove them all at once, launch Exchange 2007 powershell comand and run the below command titled ‘Command to remove disconnected Exchange 2007 mailboxes’.   (Amend server and database name as required)

Before the removal of each mailbox you will be prompted to confirm deletion, choose the option to delete one by one. So after running the command type ‘y’ and press enter, check that your disconnected mailbox count reduces, then you will be prompted to confirm deletion again, do the same again. You could do them all at once, but I prefer to do one at a time.

Command to remove disconnected Exchange 2007 mailboxes:

Get-MailboxStatistics -database “servername here\mailbox database name” | where {$_.disconnectdate -ne $null} | foreach {Remove-mailbox -database $_.database -storemailboxidentity $_.mailboxguid}

Command to list all Exchange 2007 disconnected mailboxes:

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

Disconnected mailbox folder empty?

If the disconnected mailbox folder within Exchange 2007 is empty, run the below command (replace database name as required)

Clean-MailboxDatabase “Database Name”

To confirm your mail box database name, run the below command:

get-mailbox database

Please follow and like us: