Backtrack:  
 
by lunarg on September 1st 2015, at 16:24

If a mailbox gets migrated or disabled (= disconnected), the mailbox is not removed from the mailbox database right away. Instead, Exchange uses the retention configuration of the mailbox database in which the mailbox was stored. This is useful if a restore of the mailbox is needed (e.g. in case of accidental deletion).

However, sometimes it may not be necessary to have the mailbox available for undelete. E.g. when you have migrated a large number of mailboxes, you may not wish to keep the old mailbox copies to free up disk space. In that case, you can manually "purge" the mailbox from the mailbox database.

Note that this only works with a disconnected mailbox. These are mailboxes that are no longer linked with an object in AD, and are in retention, waiting to be removed permanently.

Disconnected mailboxes and their reasons

When a mailbox gets disabled or migrated, the mailbox automatically gets "disconnected". This means it is no longer linked to an object in AD, and the mailbox will be tagged for removal once the retention window has passed.

The DisconnectReason attribute tells you why a mailbox was "disconnected". The most common values can be:

  • SoftDeleted
    If a mailbox gets migrated to another database, the AD user is linked to the newly migrated mailbox in the new database, and the old mailbox is disconnected and marked for removal.
  • Disabled
    This reason is set when the mailbox was "disabled" (Disable-Mailbox) or "removed" (Remove-Mailbox). This means that the link between the mailbox and the object in AD has been removed, and that the mailbox has been marked for removal. If the mailbox has been removed instead of disabled, the AD object was marked for removal as well, but the DisconnectReason is the same.

DisconnectReason will be empty if it's a normal mailbox (i.e. a mailbox which is not "disconnected").

Retrieve a list of "disconnected" mailboxes

You can use EMS to retrieve all disconnected mailboxes. Additionally, you can filter on DisconnectReason to differentiate between disabled/removed mailboxes and mailboxes that have been migrated to another mailbox database.

To retrieve a list of all disconnected mailboxes in all mailbox databases on the server:

Get-MailboxDatabase | Get-MailboxStatistics | Where {$_.DisconnectReason -ne $null} | Select DisplayName,Database,DisconnectReason

You can adjust the fields in the Select part to retrieve other information about the mailboxes.

To filter on a particular DisconnectReason, you can adjust the cmdlet:

Get-MailboxDatabase | Get-MailboxStatistics | Where {$_.DisconnectReason -like "SoftDeleted"}

Or:

Get-MailboxDatabase | Get-MailboxStatistics | Where {$_.DisconnectReason -like "Disabled"}

Purging "disconnected" mailboxes

By default, "disconnected" mailboxes will be purged (permanently removed) after the retention period has expired. By default, this is set to 14 or 30 days, and is configured separately on each mailbox database. Additionally, the retention on the database can be configured that the mailbox will remain in the database until it has been backed up.

You can manually remove a disconnected mailbox, meaning it will bypass the retention, and it will be removed immediately, without the ability to restore it later. This is done with the Remove-StoreMailbox cmdlet.

The cmdlet is pretty straight-forward in its usage, but has a few required parameters, which are there as an additional safeguard when it's used to permanently remove a disconnected mailbox:

  • It requires an exact match of the database, the mailbox to delete (by its name or its MailboxGuid), and the DisconnectReason. If any of these do not match (e.g. you provide a DisconnectReason of Disabled but the mailbox was SoftDeleted), the removal will abort.
  • You can only remove one mailbox at a time. You need to use pipelining and a ForEach loop to remove multiple mailboxes at once.

Once a mailbox has been removed using Remove-StoreMailbox, it can never again be restored (New-MailboxRestoreRequest).

To remove a single mailbox which was migrated to another database:

Remove-StoreMailbox -Database EXCHDB01 -Identity 23e73557-2c23-456b-b251-e00ae81b8363 -MailboxState SoftDeleted

Replace parameters (Database and MailboxGuid) accordingly.

To remove a single mailbox which was disabled or removed:

Remove-StoreMailbox -Database EXCHDB01 -Identity e301f8f5-fad2-4408-aa59-f1e1451388e3 -MailboxState Disabled

Purge all mailboxes that have been migrated elsewhere:

Get-MailboxStatistics -Database EXCHDB01 | Where {$_.DisconnectReason -eq "SoftDeleted"} | foreach {Remove-StoreMailbox -Database $_.Database -Identity $_.MailboxGuid -MailboxState SoftDeleted}
 
 
« November 2024»
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
 
Links
 
Quote
« You only find out who is swimming naked when the tide goes out. »
Warren Buffett