Exchange Shell: Restore / Migrate Disabled Mailbox

Full disclosure, I am not an Exchange person on any level. I know the basics of how things work but really have next to no hands-on experience with Exchange. However, I do know PowerShell.

I recently started a new gig as a Systems Engineer on a small team. One of the projects they have been working on is moving their mail system to Exchange. They made the switch late on Thursday and of course, some issues came up Friday morning.

They did things very manual, so there were some typos here and there. They misspelled one user’s name, so one of the engineers disabled the box, and simply created a new mailbox with the correct spelling assuming she didn’t have anything in her box yet. Well, it turns out, she had already moved 2 gigs of mail from the old system into the box, which was now inaccessible. No big deal, right? We can roll it back, restore it in the old system, etc. Lots of options here.

This is where I step in. I suggest moving the mail from the disabled box to the new one using Exchange Shell.

Step 1:

We need to find the GUID for the old mailbox. Both mailboxes were tied to the same AD user account, so we can’t rely on the display name alone. We want only the box which has been disabled.

Get-MailboxStatistics -Database 'Exchange-DB-Name' | Where-Object { ($_.DisplayName -match 'John Doe' ) -and ($_.Status -eq 'Disabled') } | fl

After verifying that this returns the correct mailbox, I just saved the results into a variable for later use.

$mailbox = Get-MailboxStatistics -Database 'Exchange-DB-Name' | Where-Object { ($_.DisplayName -match 'John Doe' ) -and ($_.Status -eq 'Disabled') }

Step 2:

Now that we have that done, we want to migrate the mail out of this box into the user’s new mailbox. This is done in Exchange via a restore request.

New-MailboxRestoreRequest -Name 'MirgateJohnDoe' -SourceDatabase 'Exchange-DB-Name' -SourceStoreMailbox $mailbox.MailboxGuid -TargetMailbox 'John Doe' -TargetRootFolder 'OldMailRestore' -AllowLegacyDNMismatch

Depending on the size of the restore/migration, this could take some time to complete.

Step 3:

You can check on the progress of your request by running…

Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics

And that’s it. As the restore runs the user will see the old mail gradually populate in Outlook.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s