Thursday, March 15, 2012

Exchange 2010 Scripting New-MoveRequest

Exchange 2010 New-MoveRequest can be scripted to take input form a csv and pipe into the New-MoveRequest command.

Here's how I did it...

Command required was:
New-MoveRequest -Identity "CN=Test User,OU=Your OU,OU=Another OU,DC=YourDC,DC=local" -RemoteLegacy -TargetDatabase "EXCH-DB" -RemoteGlobalCatalog "dc.olddomain" -RemoteCredential $Remote -TargetDeliveryDomain "yourdomain.com"

The unique fields required are "CN=Test User,OU=Your OU,OU=Another OU,DC=YourDC,DC=local" which is the distinguishedName of the user we are going to migrate and "EXCH-DB" which is the Exchange Database we want to put the Mailbox in.

First we need to get the distinguishedName for all the users we want to migrate. Here's the script http://sjmeyers.blogspot.com.au/2012/03/vb-script-to-get-distinguishedname-from.html

Then we need to setup our csv file with as the first entry in column 1 distinguishedName, the first entry in column 2 TargetDB.
Then insert the required data


Save the csv as mbusers.csv on the Exchange Server

In Exchange Power Shell

We are connecting to a remote Forest for so first we need to setup the remote credentials
$remote = Get-Credential











Make sure the csv file is in the correct directory and run the following command

import-csv mbusers.csv | foreach {New-MoveRequest -Identity $_.distinguishedName -RemoteLegacy –TargetDatabase $_.TargetDB -RemoteGlobalCatalog "dc.olddomain" -RemoteCredential $Remote -TargetDeliveryDomain "youremaildomain.com"}







If all goes well you should see the move process start.

To check on the progress run Get-MoveRequest

No comments:

Post a Comment