Tuesday, April 9, 2013

Oops - I deleted the user's mailbox... Please help

How to Relink/Restore a mailbox with the "Least Amount of Administrative Effort"

http://www.youtube.com/watch?v=JlsSy8xpsYs

yeah yeah yeah yeah yeah
Yeah yeah yeah yeah yeah yeah
 I think I did it again
I made you upset, your mailbox is gone
Oh Exchange
It might seem like a rush
But it doesn't mean that I'm oblivious
'Cause to lose all your emails
That is just so frustrating
Oh Exchange, baby
 Oops!...I did it again
I played with your mail, got lost in the shame
Oh Exchange, baby
Oops!...You think I’m the IT shiz
That I'm sent from below
I'm not that incompetent 


From time to time I run across a situation where an Admin has been a little overzealous and has either deleted the AD account for the user or disconnected the mailbox. Sometimes they create a new mailbox and call it "Macaroni" but that's like sewing a plaid sleeve on a polyester suit. Sure, it's a sleeve, but take a look in the mirror.

The other situation is when a user is "moved" between domains in the same forest. By "moved", I mean "deleted and then a new account created" in the new domain. The major issue with that is, the LegacyExchangeDN will be gone if you simply recreate the mailbox and the user won't have any items from the previous mailbox. Yes, you can have the user export their mailbox to PST before this action is done, but there's no guarantee that they grabbed everything. I've seen it happen where they grab the Inbox, but forget the Calendar or Contacts.

My solution 

A script that will either Reconnect the previous mailbox to the AD account OR perform a restore  from the previous mailbox to the new one.

The basics of my script

  • Grabs the AD User object for restoration purposes
  • Searches each mailbox server in the environment for the disconnected mailbox of the user
  • If the AD User has a mailbox
    •  A New-MailboxRestoreRequest is performed to restore the items from the disconnected mailbox to the new mailbox.
    • The disconnected mailbox's LegacyExchangeDN is added to the new mailbox as a X500 address.
  • If the AD User does not have a mailbox, 
    • The latest disconnected mailbox is connected to the AD User

Here’s the script (Relink-Mailbox.ps1) - Download 

Example Usage

Variables      
  • Mailbox 
    • The mailbox alias, SamAccountName, or GUID. This should be as unique as possible.
  • DoNotRunDatabaseCleanup
    • Prevents the script from automatically running the Clean-MailboxDatabase cmdlet


Relink-Mailbox.ps1 -Mailbox "UserA"
Script Output


04/01/2013 14:05:52 - Grabbing user's AD Object: UserA
04/01/2013 14:06:19 - Grabbing list of disconnected mailboxes
04/01/2013 14:09:25 - Connecting Mailbox
04/01/2013 14:09:57 - Waiting for AD Replication - 4 Minutes

DisplayName     Alias          WhenChangedUTC            
-----------     -----          --------------            
A, User         UserA          04/01/2013 15:03:57   




No comments:

Post a Comment