Posted on June 16, 2017 · Posted in Exchange

Managing Disconnected Mailboxes in Exchange Server

When an Exchange mailbox or an Active Directory user account is deleted, a mailbox is not immediately deleted and is stored in the mailbox database for some time (30 days by default). Administrator can recover data from this mailbox or reassign it to another user. In this article, we’ll talk about the types of deleted mailboxes and the ways of management and restore of these mailboxes in Exchange 2010-2016.

What Happens to the Exchange Mailbox After It Is Deleted

An Exchange mailbox consists of two parts: an Active Directory user account (all configuration data of a mailbox are stored in its attributes) and the mailbox itself in the Exchange mailbox database. A deleted Exchange mailbox (it may be right to say ‘disabled’) is a mailbox stored in a database, but not 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 (the first one disables a mailbox from an account, and the second one deletes the AD account as well)
  • Soft Deleted – the copies of the mailboxes saved in a storage after the mailbox is moved to another mailbox database. Thus, the data get additional protection from the issues that can occur during or after the mailbox is transferred to another database.

Both types of the deleted mailboxes are stored in the Exchange database before the expiration date specified by the administrator. The time, after which a mailbox is deleted, is specified in the settings of each Exchange database in Limits -> Keep deleted mailboxes for days (screenshots below for Exchange 2013 and Exchange 2010).

Exchange - Keep deleted mailboxes for days

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

If you need to find the deleted mailboxes in one database:

Get-MailboxStatistics –database Lon-DB1 | Where { $_.DisconnectReason -eq "Disabled" } | ft DisplayName,Database,DisconnectDate,MailboxGUID

The list of deleted mailboxes having SoftDeleted status can be obtained using the following command:

Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -eq "SoftDeleted" } | ft DisplayName,Database,DisconnectDate,MailboxGUID

List of disconnected Exchange mailboxes using Get-MailboxDatabase cmdlet

How to Clear Exchange Databases from the Deleted Mailboxes

During the specified time, Exchange automatically clears the deleted mailboxes from the database. But the disabled mailboxes still take some space in a database, so during mass user migrations/removals, it may be necessary to force remove these mailboxes, thus freeing 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

Remove-StoreMailbox  - removing disabled  mailboxes

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 you 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

A deleted mailbox may be connected to the same or another Active Directory account (obviously, the account must not have a mailbox). To connect a mailbox to the same account, run this command:

Connect-Mailbox -Identity "JSmith" -Database Lon-DB1  -User JSmith

You can perform the same operation from the EAC interface: Exchange Admin Center -> Recipients -> Connect a Mailbox.

EAC: connect deleted mailbox to a user

Tip. Don’t forget to check and correct SMTP aliases if necessary. Before you start using the mailbox, wait till Active Directory replication is over.

How to Restore a Deleted Mailbox to a Mailbox of Another User

The data from a deleted mailbox can be restored to an existing mailbox of another user using the New-MailboxRestoreRequest cmdlet (we showed how to use this cmdlet in the article about the recovery of Exchange mailboxes):

New-MailboxRestoreRequest -SourceDatabase Lon-DB1  -SourceStoreMailbox "JSmith" -TargetMailbox "Admin"

Or you 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

Previous:
Next:
Related Articles