Remove disconnected mailboxes in Exchange 2007
In Exchange 2007, there are two options to delete a mailbox:
1. Remove Mailbox
2. Disable Mailbox
If you remove a mailbox, the mailbox data that is stored in the Exchange mailbox database is marked for deletion and the associated user account is also deleted from Active Directory. If you disable a mailbox, the user account is retain, it will only disassociate the mailbox data from the user account.
Exchange retain disconnected mailboxes in the mailbox database based on the deleted mailbox retention settings configured for that mailbox database. In Exchange 2007, the default retention period is 30 days. During this time, the disconnected mailbox can be recovered by associating it with an existing Active Directory user account. After the specified retention period, a disconnected mailbox is permanently deleted from the Exchange mailbox database.
You can see the list of disconnected mailboxes in Exchange Management Console or use the cmdlet in Exchange Management Shell.
To list all disconnected mailboxes in Exchange Management Shell, run the following cmdlet.
[PS] C:\>Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid
DisplayName MailboxGuid
----------- -----------
User1 4ddc1d42-9f8e-4b02-b53f-9fb8421d9423
User2 6f067dce-24fc-4c83-b90a-532728d5b510
User3 e66197d8-d7b5-4ca6-8c25-72825dc82daf
To remove a specific disconnected mailbox, run the following cmdlet:
[PS] C:\>$Temp = Get-MailboxStatistics | Where{$_.DisplayName -eq "User3"}
[PS] C:\>Remove-mailbox -Database "Mailbox Database" -StoreMailboxIdentity $Temp.MailboxGuid
Confirm
Are you sure you want to perform this action?
Removing store mailbox "e66197d8-d7b5-4ca6-8c25-72825dc82daf" on database "server1.mydomain.com\Mailbox Database".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):Y
To remove all disconnected mailbox, run the following cmdlet:
[PS] C:\>$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database
[PS] C:\>$users | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }