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.
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:
DisconnectReason will be empty if it's a normal mailbox (i.e. a mailbox which is not "disconnected").
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"}
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:
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 | › » | ||||
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |