Exchange 2013 Create CSV for Migration Batch

Exchange 2013 Create CSV for Migration Batch

Exchange 2013 Exchange Admin Center offers the ability to create migration batches from a CSV file.

This is a pretty handy feature if you want to speed up migrating users to your new Exchange 2013 deployment or even just need to move users from one database to another. For the CSV to work it simply needs one column headed “emailaddress”, which is great but also not so great seeing as the Get-Mailbox Exchange Management Shell cmdlet returns a heading of “PrimarySMTPAddress”. This minor irritation is no big deal, we can just re-label the column as part of the script.

So here is an example of a script that I use frequently when doing Exchange 2010 to Exchange 2013 migrations:

$OU = read-host "Which OU?"
$filepath = read-host "Filepath for CSV?"
get-mailbox -OrganizationalUnit $OU | select-object @{Expression={$_.primarysmtpaddress};Label="emailaddress"} | export-csv $filepath\"OU"$OU"batch.csv" -NoTypeInformation

This script lets me create mailbox move requests for users in a certain OU. It first of all asks you a couple of questions, just tell it which OU followed by the folder path where you want the CSV to end up. Please note though if you have multiple OU’s with the same name you will need to enter the full DN instead.

Once the script has run you can go to Exchange Admin Center and start a new local move request and then select “specify the users with a CSV file” and choose your CSV. Complete the wizard and you will see all users from your chosen OU queued up to move database.

CSVMigration

 

Of course this script can easily be modified to get mailboxes from variables other than OU, security group for example is another option I frequently use. Another option is to get all users from one database and migrate them to another. You can also take this a step further and dispense with the GUI all together and just pipe in your output straight to the New-MigrationBatch cmdlet. Here is an example of the New-MigrationBatch cmdlet:

New-MigrationBatch –Name <name> –CSVData ([System.IO.File]::ReadAllBytes(“<full path to file>”)) –Local –TargetDatabase <dbname>

This on it’s own won’t kick off the migration batch, you will also need to execute this command:

Get-Migrationbatch | Start-MigrationBatch

We can combine these commands together into a single script or we can execute them separately. Every environment is different, for some migrating by OU won’t be appropriate so have a play around and see what works in your environment.

As always I hope this has been helpful to somebody. Thanks for reading.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>