Monday, October 21, 2013

Removing Disconnected Mailboxes in Exchange 2013

In most cases, waiting the default 30 days for disconnected (disabled) mailboxes to be removed is not a concern. However, when doing implementation testing, you might have significant data that you want to remove before doing a final migration with good data.

Also, when moving mailboxes, the source mailbox is soft deleted and not purged for 30 days. If you were moving mailboxes to free up space in the database, then purging soft deleted mailboxes immediately is a reasonable way to go.

In Exchange 2010 you could purge disconnected mailboxes from the Exchange Management Console. In Exchange 2013, your only option is the Exchange Management Shell.

You can use the following to remove disabled/disconnected mailboxes from a specific database:
Get-MailboxStatistics -Database “YourDatabaseName″ | where {$_.DisconnectReason -eq “SoftDeleted”} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState Disabled -Confirm:$False
You can use the following to remove soft deleted mailboxes:
Get-MailboxStatistics -Database “YourDatabaseName″ | where {$_.DisconnectReason -eq “Disabled”} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted -Confirm:$False
To modify either of these to work for all databases in your organization, replace the Get-MailboxStatistics cmdlet with the following:
Get-Database | Get-MailboxStatistics | where ....

No comments:

Post a Comment