locked
Powershell scripts for migrating users from Exchange Server to Microsoft Online RRS feed

  • Question

  • Hello!

    I am looking for scripts that can be run from Powershell that will migrate a users mailbox from an Exchange server to the Microsoft Online service.   I plan on going live within a few weeks and want to do it via a scripted process, not the GUI.

     

    Thank you!

    Ben Wilcox

    Wednesday, November 19, 2008 11:00 PM

Answers

  •  

    Here is a simple script that I have created for migrating a batch of users in PowerShell.

     

    Code Snippet

    ############################################################################

    ## Migrate.PS1

    ##

    ## Simple Migration Script

    ##

    ## Developed By: Erik Ashby

    ## Erikash@microsoft.com

    ##

    ## Description:

    ## This is a simple script that will import a list of users and migrate them to Microsoft Online

    ##

    ##

    ## migration_users.CSV format

    ## This file is a simple CSV file with the login ID of a set of users to be migrated

    ##  This file must have the following headders:

    ## "Alias"

    ## SampleUser1

    ## SampleUser2 etc.

    ##

    ############################################################################

     

    begin

    {

       # Initalize the script

       # Make sure Snap-in

       Add-PSSnapin microsoft.exchange.transporter

      

       # Get the credentials that will be used to do a migration 

       # This needs to set to the Microsoft Online Admin Account for the migration

       $tcreds=get-credential

     

    }

    process

    {

     

     

                    # load list user into memory

                    $migration_users = Import-Csv "migration_users.csv"

                   

                    #Main loop

                    foreach ($current_user in $migration_users)

                    {             

     

                                    ### Set the variables that will be used for migration

                                    ###

                                    $SourceIdentity = $current_user.Alias

     

                                    ## Start a Transcript

                                    $file="C:\logs\"

                                    $file+= $SourceIdentigy

                                    Start-Transcript $file -append

                                    "Starting a Migration for:"

                                    $SourceIdentity

                                    Date

                                    "********************************************"

     

                                    ###########################################################  

                                    ## Perform a migration. This is calling the Move-Mailbox ##

                                    ###########################################################

                                    Measure-Command {Move-XsExchangeMailboxToMicrosoftOnline $SourceIdentity -TargetCredential $tcred -maxthreadcount 50 -v}

     

                                    ## Alternate way to perform a migration when the source server does not allow SSL

                                    ## Measure-Command {Move-XsExchangeMailboxToMicrosoftOnline $SourceIdentity -TargetCredential $tcred -maxthreadcount 50 -allowunsecureconnection -v}

                    }

    }

    end{}

     

     

     

    Thursday, November 20, 2008 8:28 PM

All replies

  •  

    Here is a simple script that I have created for migrating a batch of users in PowerShell.

     

    Code Snippet

    ############################################################################

    ## Migrate.PS1

    ##

    ## Simple Migration Script

    ##

    ## Developed By: Erik Ashby

    ## Erikash@microsoft.com

    ##

    ## Description:

    ## This is a simple script that will import a list of users and migrate them to Microsoft Online

    ##

    ##

    ## migration_users.CSV format

    ## This file is a simple CSV file with the login ID of a set of users to be migrated

    ##  This file must have the following headders:

    ## "Alias"

    ## SampleUser1

    ## SampleUser2 etc.

    ##

    ############################################################################

     

    begin

    {

       # Initalize the script

       # Make sure Snap-in

       Add-PSSnapin microsoft.exchange.transporter

      

       # Get the credentials that will be used to do a migration 

       # This needs to set to the Microsoft Online Admin Account for the migration

       $tcreds=get-credential

     

    }

    process

    {

     

     

                    # load list user into memory

                    $migration_users = Import-Csv "migration_users.csv"

                   

                    #Main loop

                    foreach ($current_user in $migration_users)

                    {             

     

                                    ### Set the variables that will be used for migration

                                    ###

                                    $SourceIdentity = $current_user.Alias

     

                                    ## Start a Transcript

                                    $file="C:\logs\"

                                    $file+= $SourceIdentigy

                                    Start-Transcript $file -append

                                    "Starting a Migration for:"

                                    $SourceIdentity

                                    Date

                                    "********************************************"

     

                                    ###########################################################  

                                    ## Perform a migration. This is calling the Move-Mailbox ##

                                    ###########################################################

                                    Measure-Command {Move-XsExchangeMailboxToMicrosoftOnline $SourceIdentity -TargetCredential $tcred -maxthreadcount 50 -v}

     

                                    ## Alternate way to perform a migration when the source server does not allow SSL

                                    ## Measure-Command {Move-XsExchangeMailboxToMicrosoftOnline $SourceIdentity -TargetCredential $tcred -maxthreadcount 50 -allowunsecureconnection -v}

                    }

    }

    end{}

     

     

     

    Thursday, November 20, 2008 8:28 PM
  • Hi Ben, you can also run the Transporter Migration Application, hit the F1 key, which will bring up the Help file for the Transporter Application.  Within the Help File, towards the end of the sections, is a very large section of content regarding the Transporter PowerShell scripts, which ultimately power the Transporter GUI itself.

    People use the PowerShell scripts specifically when they want/need additional features/functions, reporting options, etc which may not be in the GUI.

    ...Ryan
    Ryan J. Phillips
    • Proposed as answer by Ryanph [MSFT] Sunday, January 11, 2009 6:51 AM
    Sunday, January 11, 2009 6:50 AM
  • There are some typos in your code ... so it won't work.  For instance "$tcreds", and then you reference it as "$tcred" in the code.

    Also, the following is incorrect: Move-XsExchangeMailboxToMicrosoftOnline

    It tells me it's not a recognized command, should be:

    Move-XsExchangeMailboxToExchangeOnline

    After making those changes, it worked.

    Great WORK!!!  Many thanks for sharing this.

    PS: for my environment, i did have to use the argument "-allowunsecureconnection" ... just in case others have problems, try that.

    Wednesday, December 15, 2010 2:37 AM