Mailboxes of the disconnected users are not immediately deleted in an Exchange server.
As a part of our Server Management Services, we help our Customers to fix Exchange related errors regularly.
Let us today discuss the steps to manage disconnected mailboxes in Exchange Server.
What happens to disconnected mailboxes in an Exchange server?
After deleting an Exchange mailbox or an Active Directory user account, it stores the mailbox in the mailbox database for some time. By default, the exchange server keeps it for 30 days.
The administrator can recover data from this mailbox or reassign it to another user.
An Exchange mailbox consists of two parts:
- An Active Directory user account (It stores all configuration data of a mailbox in its attributes)
- The mailbox in the Exchange mailbox database.
A deleted Exchange mailbox will be available in the database, but will not be connected to any of the AD accounts.
There are two types of deleted Exchange mailboxes:
- Disabled – these are mailboxes disabled using Disable-Mailbox or Remove-Mailbox cmdlets
- Soft Deleted – the copies of the mailboxes saved in storage after moving mailbox to another mailbox database.
Common operations with deleted mailboxes
To display the list of all available deleted mailboxes in all Exchange databases, run this command:
Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -eq "Disabled" } | ft DisplayName,Database,DisconnectDate,MailboxGUID
Now, to find the deleted mailboxes in one database:
Get-MailboxStatistics –database Lon-DB1 | Where { $_.DisconnectReason -eq "Disabled" } | ft DisplayName,Database,DisconnectDate,MailboxGUID
We can obtain the list of deleted mailboxes having SoftDeleted status using the following command:
Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -eq "SoftDeleted" } | ft DisplayName,Database,DisconnectDate,MailboxGUID
How to Clear Exchange Databases from the Deleted Mailboxes
Exchange automatically clears the deleted mailboxes from the database after the specified time.
But the disabled mailboxes still take some space in a database. Thus during mass user migrations/removals, it may be necessary to force remove these mailboxes to free some space in the mail databases.
To permanently delete a disabled mailbox from the database, use Remove-StoreMailbox cmdlet having specified the MailboxGUID of the deleted mailbox.
Remove-StoreMailbox -Database Lon-DB1 -Identity "2532944e-8eeb-4c7e-8bd3-ee2a223b071e" -MailboxState Disabled
To delete all disabled mailboxes in the Exchange organization:
Get-MailboxDatabase | Get-MailboxStatistics | where {$_.DisconnectReason -eq "Disabled"} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}
If we have to delete mailbox copies left after the migration in a specific database, run the following command:
Get-MailboxStatistics –Database Lon-DB1 | Where-Object {$_.DisconnectReason –eq “Softdeleted”} | ForEach {Remove-StoreMailbox –Database $_.database –identity $_.mailboxguid –MailboxState Softdeleted –Whatif
Connecting a Deleted Mailbox to a User
We can connect a deleted mailbox to the same or another Active Directory account. To connect a mailbox to the same account, run this command:
Connect-Mailbox -Identity "JSmith" -Database Lon-DB1 -User JSmith
We can perform the same operation from the EAC interface via Exchange Admin Center -> Recipients -> Connect a Mailbox.
Do not forget to check and correct SMTP aliases if necessary. Before we start using the mailbox, wait till Active Directory replication is over.
How to Restore a Deleted Mailbox to a Mailbox of Another User
We can restore the data from a deleted mailbox to an existing mailbox of another user.
New-MailboxRestoreRequest -SourceDatabase Lon-DB1 -SourceStoreMailbox "JSmith" -TargetMailbox "Admin"
Similarly, we can restore the mailbox by its MailboxGuid, say, to a separate folder RestoreBox:
New-MailboxRestoreRequest -SourceDatabase Lon-DB1 -SourceStoreMailbox “2532944e-8eeb-4c7e-8bd3-ee2a223b071e” -TargetMailbox “Admin” –TargetRootFolder “RestoreBox” –AllowLegacyDNMismatch
[Need any further assistance to manage disconnected mailboxes in Exchange Server? – We’re available 24*7]
Conclusion
In short, after deleting an Exchange mailbox or an Active Directory user account, it stores the mailbox in the mailbox database for some time. Today, we saw how our Support Engineers manage disconnected mailboxes in Exchange Server.
0 Comments