Find and export disconnected mailboxes

In Exchange 2010/2013 you might find yourself in a position to need to export disconnected mailboxes. Say if someone leaves and their account is deleted, leaving the mailbox in a ‘Disabled’ state for the retention period.

First thing you need to do is find the mailbox as it won’t appear when it’s disconnected.

Get-MailboxStatistics will do this.

Get-MailboxDatabase DatabaseName | Get-MailboxStatistics | ?{$_.DisconnectReason -notlike $null} | FT DisplayName, Database -autosize

 

 

Get-MailboxDatabase DatabaseName | Get-MailboxStatistics |
?{$_.DisconnectReason -notlike $null} | FT DisplayName, Database -autosize

If this is likely to return lots of results you might want to narrow down with adding more search criteria

So once you have the mailbox you can get the information you need to retrieve it. Probably the safest way is to return the displayName and MailboxGuid.

You’ve then got a couple of options with what to do with the date. You could simply reattach it to a new AD Account and access the mailbox with Outlook. This isn’t always practical in a large environment, particularly where getting AD Accounts created can be a bit of a saga.

I like the New-MailboxRestoreRequest which allows you to restore a mailbox that is in a disconnected state. In the above example where an AD Account has been removed, the Mailbox will be in a disconnected state of ‘Disabled’ until the information store has decided it’s past its retention period, and will then be deleted.

To create a restore request, you must provide the DisplayName, LegacyDN, or MailboxGUID for the soft-deleted or disabled mailbox.

Example usage:

New-MailboxRestoreRequest -SourceDatabase DatabaseName `
-SourceStoreMailbox {MailboxGuid} -TargetMailbox SMPTAddress@domain.com `
-TargetRootFolder "Restore" -TargetIsArchive -AllowLegacyDNMismatch `
-Name NameTheRequest

So this sets up a new restore request.

If you’re restoring to another mailbox, or new mailbox, you need to use the -AllowLegacyDNMismatch switch or it will Error. Not entirely sure why but I’m guessing it’s Microsoft way of writing in a sanity check.

Use the -Name switch to easily name the request. Helps if you’re gonna want to keep an eye on it.

You can use the Get-MailboxRestoreRequest and Get-MailboxRestoreRequestStatistics to get a view of how it’s progressing.

With the above example that would be

Get-MailboxRestoreRequest -Name NameTheRequest |
    Get-MailboxRestoreRequestStatistics | Fl

Obviously use a name that’s meaningful to you.

If you don’t use the -TargetIsArchive switch the data will be restored directly into the Target users mailbox.

Gotchas
So couple of things you need to be careful of.

1. Obviously you need to make sure the target mailbox needs to have the available space to take the data you’re restoring.
2. Keep in mind that the restore also restores hidden system folders like Recoverable Items folder and they can be huge.

Leave a Reply

Your email address will not be published. Required fields are marked *