When you’re planning to migrate Exchange mailboxes you might choose to create lists of users to move and store them in text files.  With the Exchange Management Shell you can then use the text files as inputs to PowerShell commands to execute the moves.

This method starts with the Get-Content PowerShell command.  Get-Content can be used to read in a list of mailboxes from a text file, for example:

[PS] C:\>Get-Content C:\Admin\users.txt
Aisha.Bhari
Andrew.O'Grady
Denise.Dartnell
Garth.Gibbons
Harinder.Rahman
Jagir.Ward
Jas.Dowden
Joanna.Hughes
Joy.Singh
Laoise.Curtis
Lydia.Haines
Maggie.Hengist
Michael.Phillips
Nancy.Scott
Pakwei.Dean
Prathee.Dar
Ravi.Edmonds
Rowena.Khan
Sharmila.Hafri
Stuart.Beauchamp
Tina.Miller
Wendy.Fyson
TestMB BR

This output can then be piped to the commands that are used to move the mailboxes. For Exchange Server 2007 this would be:

[PS] C:\>Get-Content C:\Admin\users.txt | Move-Mailbox -TargetDatabase DATABASENAME  -Confirm:$false

Note the -Confirm:$false that prevents you from having to manually confirm each move.

For Exchange Server 2010 mailbox moves the commands are different:

[PS] C:\>Get-Content C:\Admin\users.txt | New-MoveRequest -TargetDatabase MB-HO-01

Note that if you wanted to test your command syntax without actually moving the mailboxes just use the -WhatIf paramater, for example:

[PS] C:\>Get-Content C:\Admin\users.txt | New-MoveRequest -TargetDatabase MB-HO-01 -WhatIf
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Aisha.Bhari".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Andrew.O'Grady".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Denise.Dartnell".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Garth.Gibbons".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Harinder.Rahman".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Jagir.Ward".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Jas.Dowden".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Joanna.Hughes".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Joy.Singh".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Laoise.Curtis".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Lydia.Haines".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Maggie.Hengist".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Michael.Phillips".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Nancy.Scott".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Pakwei.Dean".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Prathee.Dar".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Ravi.Edmonds".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Rowena.Khan".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Sharmila.Hafri".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Stuart.Beauchamp".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Tina.Miller".
What if: Creating move request "exchangeserverpro.net/Company/Users/Branch Office/Wendy.Fyson".
What if: Creating move request "exchangeserverpro.net/Users/TestMB BR".

When the moves are complete you can use a similar technique to verify that each user in the list was moved successfully to the target database.

[PS] C:\>Get-Content C:\Admin\users.txt | Get-Mailbox | ft name,database

Name                                                        Database
----                                                        --------
Aisha.Bhari                                                 MB-BR-01
Andrew.O'Grady                                              MB-BR-01
Denise.Dartnell                                             MB-BR-01
Garth.Gibbons                                               MB-BR-01
Harinder.Rahman                                             MB-BR-01
Jagir.Ward                                                  MB-BR-01
Jas.Dowden                                                  MB-BR-01
Joanna.Hughes                                               MB-BR-01
Joy.Singh                                                   MB-BR-01
Laoise.Curtis                                               MB-BR-01
Lydia.Haines                                                MB-BR-01
Maggie.Hengist                                              MB-BR-01
Michael.Phillips                                            MB-BR-01
Nancy.Scott                                                 MB-BR-01
Pakwei.Dean                                                 MB-BR-01
Prathee.Dar                                                 MB-BR-01
Ravi.Edmonds                                                MB-BR-01
Rowena.Khan                                                 MB-BR-01
Sharmila.Hafri                                              MB-BR-01
Stuart.Beauchamp                                            MB-BR-01
Tina.Miller                                                 MB-BR-01
Wendy.Fyson                                                 MB-BR-01
TestMB BR                                                   MB-BR-01

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. MannyO

    Jesus, this is so simple…
    Thank you for this. It’s exactly what I’m looking for.
    I’m migrating 500 users in batches from a 2013 to a 2016 and I’m getting the dreaded “A version mismatch was detected (Actual:6, Expected:5)” when I try to do a batch migration in the ECP.
    This powershell method saved me a lot of time.
    Thanks!

  2. Brad

    On Ex 2013 CU10 I am getting an error:
    get-content C:\—path—\moves.txt | New-moveRequest -targetDatabase “MBDB10” -whatif

    The input object cannot be bound to any parameters for the command either because the command does not take pipeline
    input or the input and its properties do not match any of the parameters that take pipeline input.
    + CategoryInfo : InvalidArgument: (:PSObject) [New-MoveRequest], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,New-MoveRequest

    1. Brad

      I removed -whatif and find that the moves do queue up and are in progress. I’d still like to know why the pipeline error occurs.

  3. Charlie Lochbaum

    OK, I understand you can also use a .CSV file to migrate Exchange 2010 mailboxes to Exchange 2016. The only documentation is for Exchange 2013 where they have you create a .CSV file with one column and heading called “EmailAddress” and place all the user’s email addresses below it. Can this be done in Exchange 2016 in PowerShell?

  4. John

    For some reason when I try this I get the error that it can’t find the path . Even when the file is clearly in the path it’s saying it can’t find… I tried the root of the C drive, I tried the desktop, and each time I changed directory to that location and the error shows the correct path that the file exists in, still saying it can’t find it. Oh well, I only have a few hundred to move, so I can just keep hitting them manually, up arrow, back arrow, type over each name…

  5. CJ Singh

    nice article Paul! helped me a lot

    To check the current migration status of the mailboxes you guys can run the following command.

    Get-MoveRequestStatistics -MoveRequestQueue “target database name” (with the quotes)

    This way you will be able to check the status of the move

  6. Philip

    I have 2 exchange 2007 servers EX001 & EX002

    Each of these have one DB each DB001 & DB002

    How can I use these commands to move a mailbox in DB001 on EX001 to DB002 on EX002.

    In GUI, 4 mailboxes are moved at a time. Can we move 4 or 5 mailboxes using these cmdlet script.

  7. Bonnie Whalon

    Looking for a simple way to move mailboxes from SBS2008 Exchange2007 to Exchange 2013 standard. Exmerge was an easy tool is there a replacement.

    I reviewed the information for Get-Mailbox but you need a 32 bit system with a 32 bit mailbox and I would need to bring a system on-site as all of the clients systems are 64 bit. If I do this I can just bring a system set it up to connect to the sbs domain and create psts by loging into each mailbox. This is suppose to get easier not harder

    Thank you for your help.

  8. Mickey

    doesn’t work for exchange 2010

      1. CJ Singh

        Works fine for Exchange 2013 and I am actually running it from the new Exchange 2016

  9. Tom

    Was able to use this with a schedule task, happy days 🙂

  10. Brett

    Thanks Paul , This help me move over 500 mailbox with out any issue .

Leave a Reply