Exchange – Delete Disconnected Mailboxes

Delete disconnected mailbox In the previous post I have shown how to use PowerShell to create a report of disconnected mailboxes, in this post I will show how to permanently delete disconnected mailboxes.

An Exchange mailbox is composed of two components the user account and the mailbox used to store the data itself the picture below perfectly illustrate this (courtesy of Technet):

Exchange Mailbox

A disconnected mailbox so it’s a mailbox that exists in the Exchange database but is not associated with any Active Directory account, disconnected mailbox are further divided in two types disabled mailboxes and soft deleted mailboxes.

A disabled mailbox is created when the associated user account is removed or either the Disable-Mailbox or Remove-Mailbox cmdlets are used, to delete disconnected mailboxes which are in a disabled state you would he the following command:

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

Soft deleted mailboxes are generated when a mailbox is moved to a different mailbox database, Exchange rather than delete the source mailbox once the move is complete puts it in a soft deleted state, to delete disconnected mailboxes which are in a soft deleted stat you would use the following command:

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

If you want to know which disconnected mailboxes are being deleted from the database you could use write the above commands similarly to:

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

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

If you want to remove a mailbox and immediately delete it from the Exchange database you can use the Permanent parameter like in this example:

Remove-Mailbox -Identity helochecklethe -Permanent $true

I hope you found the article useful, please take a moment to leave  a comment and don’t forget to subscribe to RSS for being notified of new articles!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s