Monday, July 23, 2012

Office365 Migrations and the legacyExchangeDN

I ran across this problem for a customer and thought I would share my experience/resolution.

Migration Scenario:
- Customer runs Exchange 2003 environment and RPC/HTTP is non-functional for the migration
- Using 3rd-party tools to migrate accounts
- When an internal user replies to messages from another internal user prior to migration, the sender receives an NDR with the X400 address of the legacy Exchange system

Tools required:
- ADFind (joeware.net)
- Microsoft Online Services PowerShell Module
- Text editor

1.     Run ADFIND on the customer's server.  This is the syntax I used:
adfind -csv -h -b "" -f "objectClass=user" -nodn mail legacyexchangedn > userlist.csv

2.     Clean up the email addresses in the userlist.csv file (to make sure they match the Office 365 addresses).
3.     Connect to the Office 365 tenant using PowerShell.
4.     Run the following script:

$csv = import-csv .\userlist.csv -header Username
foreach ($line in $csv)
    {   
    $user=Get-Mailbox -Identity $line.Username
    $user.EmailAddresses+="X500:"+$line.legacyExchangeDN
    Set-Mailbox -Identity $line.Username -EmailAddresses $user.EmailAddresses
    }


Let me know if this helped you out by leaving a comment.

Cheers.