Delete a disconnected mailbox from Exchange 2010


To totally unlock this section you need to Log-in


Login
As you probably already know in Exchange 2010 the Purge option disappeared and there is actually almost no easy way to remove a disconnected mailbox from the Exchange 2010 server. When you removed an users the disconnected mailbox will disappear hidden.

Things have changed slightly in 2010 SP1, atleast in the Exchange Shell world. A new command “Remove-StoreMailbox” has been introduced to purge disconnected or soft-deleted mailboxes (new in 2010 SP1).

INFO: when mailboxes are moved from a 2010 SP1 database to any other database, Exchange doesn’t fully delete the mailbox from the source database immediately upon completion of the move. Instead, the mailbox in the source mailbox database is switched to a “soft-deleted” state, known as soft-deleted mailboxes.

To get this back non-hidden you have to use an easy command in the Exchange Management Shell:

clean-mailboxdatabase "Mailbox Database 1166050598"

However you should get all information about the mailbox of the deleted user and disconnected mailbox. To get this information you should use the Exchange Management Shell. You can use the following command..

Get-MailboxStatistics -Database "Mailbox Database 1166050598" | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid

Result:

DisplayName    : USERMAN

DisconnectDate : 1-7-2010 16:00:48
MailboxGuid : def4aabd-2156-5857-858f-470efc3e6f28

Take the MailboxGuid and copy it to Notepad. For easy modification. :-)

This MailboxGuid is needed to remove the mailbox completely.

Remove-Mailbox -Database "Mailbox Database 1166050598" -StoreMailboxIdentity def4aabd-2156-5857-858f-470efc3e6f28

After this command the mailbox is defiantly gone from your Exchange server.

To check go to: Exchange Management Console (EMC) > Microsoft Exchange On-Premises > Recipient Configuration > Disconnected Mailbox.

There is a way to delete all the disconnected mailboxes. You can use the following commands to delete a bounce of mailboxes at once.

First run the command in the administrative Exchange Console (this command will store in a global variable, $mailboxes, all the mailbox in disconnected state, verifying the disconnected date:

$mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database

After this command you have to use the following command line:

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

If you have done this you can check in the exchange console if the disconnected mailboxes are gone.

Another Solution

The following is another solution to delete soft-deleted mailboxes. If you use the following command users mailboxes will be deleted for sure:

Get-MailboxStatistics -Database "" -OutBuffer 1000 | ? {$_.DisconnectReason -eq "SoftDeleted"} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}

While, if you want to remove all disconnected mailboxes from a database, run the following command:

Get-MailboxStatistics -Database "" -OutBuffer 1000 | ? {$_.DisconnectReason -eq "SoftDeleted"} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState Disabled}

1 thought on “Delete a disconnected mailbox from Exchange 2010”

Comments are closed.