Move Local Exchange Mailboxes To Exchange Online Using PowerShell

In this blog post, I will show you how to move local on-premises Exchange mailboxes to Exchange Online using PowerShell.

This process is very handy if you need to automate the move process in a hybrid configuration using a daily task.

Notes

You need to run this script from the local Exchange PowerShell console and not from Exchange online.

CSV

below, is the CSV format you will need to use to add your mailboxes.

"Emailaddress"
"emailaddress1"
"emailaddress2"

Script

Below, is the PowerShell script you will need to run, make sure you fill in the details of your Exchange and Exchange Online services.

$localexchangeadmin = Get-Credential -Credential "adminusername"
$hybridserver = "servername"
$remotedomain "TENANTNAME.mail.onmicrosoft.com"

Import-Csv .\newmailboxes.csv | `
foreach { New-MoveRequest -Identity $_.emailaddress  -Remote -RemoteHostName $hybridserver`
-TargetDeliveryDomain $remotedomain`
-RemoteCredential $localexchangeadmin  -BadItemLimit 1000 }

To fully automate the process you can use the following script to find and export newly created mailbox to a CSV file and use it to move the mailboxes to Exchange Online.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.