Skip to content

Migrate Exchange mailboxes through text file

You want to migrate users to a new database or new Exchange Server. You can migrate mailboxes with the Exchange Admin Center (EAC) and select the users one by one or work with PowerShell. This article will show you how to migrate Exchange mailboxes through a text file with PowerShell. This way, you can make multiple text files with users and migrate each batch to an Exchange mailbox database.

Configure the text file

Open up Notepad and fill in the e-mail addresses that you want to migrate.

Migrate Exchange mailboxes through text file add addresses.png

Save it as a text file called migrate1.txt and place it in the following path C:\migrate on your Exchange Server. If you don’t have a folder called migrate, create it.

Migrate Exchange mailboxes through text file create text file.png

Do you need a list of all the mailboxes in a database or entire organization? Have a look at the article Get mailbox size of all users in Exchange with PowerShell.

Read the text file

Run Exchange Management Shell as administrator. Change directory to the migrate folder path and read the text file. It will display the content of the text file.

[PS] C:\>cd "C:\migrate"

[PS] C:\migrate>Get-Content "migrate1.txt"
john.doe01@alitajran.com
john.doe02@alitajran.com
john.doe03@alitajran.com
john.doe04@alitajran.com
john.doe05@alitajran.com
john.doe06@alitajran.com
john.doe07@alitajran.com
john.doe08@alitajran.com
john.doe09@alitajran.com
john.doe10@alitajran.com

List the databases included count mailboxes

Before you move mailboxes, it’s always good to verify the target mailbox database. Run the following command to list the databases in the organization.

[PS] C:\migrate>Get-Mailbox -ResultSize Unlimited | Group-Object -Property:Database | Select-Object Name,Count | Sort-Object Name | Format-Table -Auto

Name      Count
----      -----
DB01         20
DB02         31
DB03         46
DB05         55
DB06         29

Migrate mailboxes through a text file to a particular database

Suppose you want to migrate the mailboxes to the DB03 database, run the command with the -WhatIf parameter placed at the end. The -WhatIf parameter allows you to see what will happen if you run the command. No changes will be made.

[PS] C:\migrate>Get-Content "migrate1.txt" | New-MoveRequest -TargetDatabase "DB03" -WhatIf
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe01 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe02 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe03 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe04 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe05 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe06 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe07 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe08 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe09 John".
What if: Creating move request "alitajran.local/AT/Users/Standard/Doe10 John".

Run the command without the -WhatIf parameter to migrate the mailboxes to the database.

[PS] C:\migrate>Get-Content "migrate1.txt" | New-MoveRequest -TargetDatabase "DB03"

DisplayName StatusDetail        TotalMailboxSize               TotalArchiveSize PercentComplete
----------- ------------        ----------------               ---------------- ---------------
Doe01 John  WaitingForJobPickup 5.063 KB (5,184 bytes)                          0
Doe02 John  WaitingForJobPickup 2.423 MB (2,540,313 bytes)                      0
Doe03 John  WaitingForJobPickup 302.3 KB (309,603 bytes)                        0
Doe04 John  WaitingForJobPickup 4.377 MB (4,589,389 bytes)                      0
Doe05 John  WaitingForJobPickup 231.6 MB (242,877,775 bytes)                    0
Doe06 John  WaitingForJobPickup 3.148 GB (3,379,905,224 bytes)                  0
Doe07 John  WaitingForJobPickup 1.246 GB (1,337,894,754 bytes)                  0
Doe08 John  WaitingForJobPickup 5.301 GB (5,691,380,553 bytes)                  0
Doe09 John  WaitingForJobPickup 498.9 MB (523,091,486 bytes)                    0
Doe10 John  WaitingForJobPickup 5.32 GB (5,711,868,104 bytes)                   0

Suspend the migration

If you want to suspend (pause) the migration, use the Suspend-MoveRequest cmdlet.

[PS] C:\migrate>Get-Content "migrate1.txt" | Suspend-MoveRequest

Confirm
Are you sure you want to perform this action?
Suspending move request "Doe01, John".  Suspending this move request will prevent data from being
replicated until it is manually resumed by using the Resume-MoveRequest cmdlet.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): A

Verify the suspend status

[PS] C:\migrate>Get-Content "migrate1.txt" | Get-MoveRequest | Get-MoveRequestStatistics

DisplayName StatusDetail TotalMailboxSize             TotalArchiveSize PercentComplete
----------- ------------ ----------------             ---------------- ---------------
Doe01 John  Suspend      5.063 KB (5,184 bytes)                        20
Doe02 John  Suspend      2.423 MB (2,540,313 bytes)                    15
Doe03 John  Suspend      302.3 KB (309,603 bytes)                      10
Doe04 John  Suspend      4.377 MB (4,589,389 bytes)                    10
Doe05 John  Suspend      231.6 MB (242,877,775 bytes)                  10
Doe06 John  Suspend      3.148 GB (3,379,905,224 bytes)                10
Doe07 John  Suspend      1.246 GB (1,337,894,754 bytes)                10
Doe08 John  Suspend      5.301 GB (5,691,380,553 bytes)                10
Doe09 John  Suspend      498.9 MB (523,091,486 bytes)                  10
Doe10 John  Suspend      5.32 GB (5,711,868,104 bytes)                 10

Resume the migration

When you want to resume the migration, make use of the Resume-MoveRequest cmdlet.

[PS] C:\migrate>Get-content "migrate1.txt" | Resume-MoveRequest

Check status of the migration

Run the following command to check the status of the migration.

[PS] C:\migrate>Get-Content "migrate1.txt" | Get-MoveRequest | Get-MoveRequestStatistics

DisplayName StatusDetail    TotalMailboxSize               TotalArchiveSize PercentComplete
----------- ------------    ----------------               ---------------- ---------------
Doe01 John  CopyingMessages 5.063 KB (5,184 bytes)                          23
Doe02 John  CopyingMessages 2.423 MB (2,540,313 bytes)                      22
Doe03 John  CopyingMessages 302.3 KB (309,603 bytes)                        45
Doe04 John  CopyingMessages 4.377 MB (4,589,389 bytes)                      31
Doe05 John  CopyingMessages 231.6 MB (242,877,775 bytes)                    84
Doe06 John  CopyingMessages 3.148 GB (3,379,905,224 bytes)                  73
Doe07 John  Completed       1.246 GB (1,337,894,754 bytes)                  100
Doe08 John  Completed       5.301 GB (5,691,380,553 bytes)                  100
Doe09 John  Completed       498.9 MB (523,091,486 bytes)                    100
Doe10 John  Completed       5.32 GB (5,711,868,104 bytes)                   100

You can also check if the e-mail addresses in the text file got migrated to the target database.

[PS] C:\migrate>Get-Content "migrate1.txt" | Get-Mailbox | Format-Table Name, Database

Name        Database
----        --------
Doe01 John  DB03
Doe02 John  DB03
Doe03 John  DB03
Doe04 John  DB03
Doe05 John  DB03
Doe06 John  DB03
Doe07 John  DB03
Doe08 John  DB03
Doe09 John  DB03
DOe10 John  DB03

The mailboxes migrated successfully to the target database. Did you migrate a text batch with mailboxes to a database in Exchange?

Keep reading: Export a list of mailboxes to text in Exchange »

Conclusion

You learned how to migrate Exchange mailboxes through a text file. Migrating mailboxes with a text file in Exchange is excellent to do. The exact steps and the right approach are essential if you need to migrate a lot of users. If you can make batches of the mailboxes in text files and select a target database for each batch, you can migrate fast. It’s also nice that you can quickly verify if the mailboxes in the text file got migrated to the target database.

Did you enjoy this article? You may also like Outlook not connecting to Exchange after migration. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 8 Comments

  1. Just wanted to say that I’ve been using your posts to migrate to Exchange 2019. Thank you very much for the help…it has been invaluable!

  2. What’s the correct command to move the primary mailbox to one database (DB01) and the archive mailbox to another database (DB02)?

  3. Could it be possible for us to add (-priority emergency) parameter in the end of the exporting command to prevent disk latency?

    1. Yes, you can do that.

      The command will look like this:

      Get-Content "migrate1.txt" | New-MoveRequest -TargetDatabase "Database" -Priority Emergency

      Fill in your target database in the above “Database” field.

  4. What an excellent essay this is. I don’t know I can thank you. This is the very best solution for bulk user mailbox migration. I had been looking for a script to migrate through CSV file! This is the easiest way!

Leave a Reply

Your email address will not be published. Required fields are marked *