Welcome to Exchange Team Blog Sign in | Join | Help

Syndication

This Blog

Cross Org mailbox migration cleanup with Exchange Server 2007

After performing a Cross Org mailbox migration, administrators need to enable mail redirection from the source to the target forest. Even though GALSync remains the recommended tool for this purpose, the initial synchronization process can take some time which means that messages queued during the move and messages sent from users in the source forest before the contacts objects were created will NDR.

To address this issue, Exchange 2007 added to Move-mailbox a parameter called SourceMailboxCleanupOptions to determine what "source cleanup" will be done after the move.

For RTM, this parameter accepts 2 options:

  • DeleteSourceMailbox: Deletes mailbox attributes from source user
  • DeleteSourceNTAccount: Deletes source user AD object

These two options don't address completely the issue but allow easier scripting than we had in the Exchange 2003 days. To fully support our additional cleanup needs we have added 2 new options for this parameter in SP1:

  • CreateSourceContact: Deletes source user AD object and creates a contact on the source forest that points to the mailbox just moved to the target forest
  • MailEnableSourceAccount: Deletes mailbox attributes from source user and mail enables the source user so it points to the mailbox just moved to the target forest

Workaround for Exchange 2007 RTM: A cross org migration cleanup script

As I mentioned above, our RTM version has an improved but incomplete "cleanup" functionality. To help our customers to perform these cleanup options before Service Pack 1 is released, I have created a PowerShell script that provides similar functionality: It creates a mail enabled contact (when the option to delete the source user is used) or it can mail enable the user account (when the option to delete the source mailbox attributes is used).

It is worth noticing that this script has some limitations when compared to our SP1 move-mailbox task:

  • It has to be executed from the source Forest
  • Logging is not as detailed as the actual move-mailbox native log
  • Since the script needs to be executed from the source Forest it will not work when the source Forest does not have a Exchange 2007 server installed

Here is an overview of the steps performed by the script:

  • Pre-validates CSV and parameters
  • Store data about mailboxes that will be moved to be used later
  • Try to move all mailboxes. Check whether task was successful. If not, stop execution
  • Use the newly moved mailbox primary SMTP address as the External email address
  • If creating a contact:
    • Creates contact object and uses mailbox display name as contact name
    • Use mailbox alias as alias if creating contact
  • Copy proxies from moved mailbox as secondary proxies
  • Try to add target mailbox SMTP to proxy collection (it is necessary if address was calculated for a Ti target server)
  • Add target mailbox LegDN as X500 to proxy collection

Here is an example of a mailbox migration using the script:

Step 1 – Create variables that hold credentials for source and target Forests

$source = get-credential
$target = get-credential

Step 2 – Create a csv file that contains information about the mailboxes you want to migrate (for example, mailboxes that have contain Paul in identity)

get-mailbox Paul* | export-csv C:\users.csv

Step 3 – Call script passing all necessary information:

C:\migrationCleanup>.\migrationCleanup.ps1 -SourceGlobalCatalog sourceServer.SourceDomain.com -SourceDomainController sourceServer.SourceDomain.com -DomainController targetServer.TargetDomain.com -GlobalCatalog targetServer.TargetDomain.com -NTAccountOU 'CN=Users,DC= TargetDomain ,DC=com' -ContactsOU "Users" -UsersFile "C:\users.csv" -TargetDatabase " targetServer \Mailbox Database" -SourceMailboxCleanupOptions DeleteSourceMailbox -SourceForestCredential $source -TargetForestCredential $target -TargetSMTPDomain "TargetDomain.com"

In this example, I had the following server configuration:

-SourceGlobalCatalog

sourceServer.SourceDomain.com

-SourceDomainController

sourceServer.SourceDomain.com

-DomainController

targetServer.TargetDomain.com

-GlobalCatalog

targetServer.TargetDomain.com

-NTAccountOU

'CN=Users,DC=FRICIB-dom,DC=extest,DC=microsoft,DC=com'

-ContactsOU

"Users"

-UsersFile

"C:\users.csv"

-TargetDatabase

" targetServer\Mailbox Database"

-SourceMailboxCleanupOptions

DeleteSourceMailbox

-SourceForestCredential

$source

-TargetForestCredential

$target

-TargetSMTPDomain

"TargetDomain.com"

Most parameters work the same way they do in move-mailbox. The exceptions are –ContactsOU, which determines where your source contact will be created and the parameter –TargetSMTPDomain, which is used when moving mailboxes to legacy Exchange servers. In these cases, the target SMTP address is stamped in the target mailbox by the RUS, which means it might not be present right away. Since we need that target address to be used as the –ExternalEmailAddress of the newly created source mail contact or mail enabled user, we will use the –TargetSMTPDomain parameter along with the alias of the source mailbox as a substitute for it.

Besides the limitations mentioned earlier (and all the optimizations I know you will come up with), this script should work just fine and allow you to avoid the large majority of NDRs for email sent during and after a Cross Org mailbox move.

You can get the migration cleanup script here:

migrationCleanup.ps1 script

- Paul MacKnight

Published Monday, July 16, 2007 12:18 PM by Exchange
Filed Under: , , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Robert said:

Off topic, but I can't get your Ehloidea at microsoft . com email suggestion address to work.
July 16, 2007 3:46 PM
 

Exchange said:

Robert,

Thanks, I just reproduced this problem and am looking into it.

In the mean time - you can email the idea to me at: ninob AT microsoft DOT com
July 16, 2007 4:07 PM
 

Elan said:

We tried using the export-csv this week for another problem and noticed that it would only export the primary e-mail address to the csv file.  The users have multiple e-mail addresses assigned.  That right there made export-csv useless to us.  Is there a way to have export-csv export all e-mail addresses assigned to a user?
July 16, 2007 4:40 PM
 

Anthony said:

Maybe I am missing something, but since this PS1 script must be run in the source domain, how is it any different from the following VBScript (barring the piping of a user list)

DIM strUserDN   '*** This is the distinguished name of the user (string)
DIM objUser  '*** Object variable for containing the user
DIM strEmailAddr '*** Populate with the external email address of the mail-enabled user

'*** Set variables
strUserDN = "[Distinguished Name of Account]"  
strEmailAddr = "[email address]"

'*** Get user object
wscript.echo "Connecting to user " & strUserDN
Set objUser = GetObject("LDAP://" & strUserDN)

'*** Wipe out the existing Mailbox
wscript.echo "Removing mailbox"
objUser.DeleteMailBox
objUser.SetInfo()

'*** Okay, now let's mail-enable it
wscript.echo "mail-enabling the user with address: " & strEmailAddr
objUser.MailEnable strEmailAddr
objUser.Put "internetEncoding",1310720
objUser.SetInfo()
July 16, 2007 6:18 PM
 

Paul MacKnight said:

Elan,
I am not sure about this, I can try to repro here and forward to some PowerSheel guy. But regarding this script, it should not matter because the csv only provides the ID, we get the proxies from cmdlets.

Anthony,
That's not exactly what we do. We set the target address on the contact, copy the new legDN as X500, copy primary SMTPs as secondary, and other things. Besides that, we also differentiate between creating a contact and a mail enabled user.

Thanks
July 16, 2007 7:55 PM
 

Exchange said:

Robert,

BTW - we have fixed the ehloidea problem, thanks again for reporting it!
July 18, 2007 1:54 PM
 

Robert Rebbibnav said:

This all seems pretty convoluted.  Are there any third party tools that handle all this?

I only know of 2 companies right now that seem to support migrations to 2007, and only one of them, Priasoft, seems to support this "Contact" thing as well as other things.

Does anybody at MS or otherwise have any experience or comments about these third-party tools?
July 18, 2007 8:28 PM
 

Paul MacKnight said:

Robert,
You are right, Cross Org migrations are a bit complex. I am not aware of any tools (Quest had a 2003 migration tool) but I don't believe the complexity will decrease just by using other tools.

If you have any specififc questions just send me an email: paul.macknight at microsoft.com and I will be glad to help you.

Paul
July 19, 2007 8:10 PM
 

Josh Prine said:

I am doing a 2000 to 2007 transition. Most users are moved however I am getting this error message on the few that are left. There is no storage limits on any stores or mailboxes. I have been able to create a new mailbox on 2000 and move it 2007 just find. I have ran the cleanup agent on 2000. how do you do it on 2007.

Error was found for User (User@domain.com) because: Error occurred in the step: Preparing mailbox to be moved. Failed to copy basic mailbox information with error: After moving a mailbox, you must wait for cleanup operations to complete before you can move it again., error code: -1056749241
September 27, 2007 10:13 AM
 

mklyotskin@hotmail.com said:

Is it possible to do cross-org from Exchange 2007 back to 2003 with 2003 wizard?
October 9, 2007 7:45 AM

What do you think?

(required) 
(optional)
 
Enter the code you see below

(required) 

News

This is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified in the Terms of Use.

New! Would you like to suggest a topic for the Exchange team to blog about? Send suggestions to us.

Poll: