Migrate Exchange Mailbox to Exchange Online Using PowerShell

In this blog post, I’ll show you how to migrate a user mailbox In a hybrid Configuration to Exchange Online using PowerShell.

Using PowerShell to move hybrid mailboxes can same many clicks If using the migration wizard from the Office 365 portal.

In my current environment, I have Exchange Server 2016 In Hybrid configuration with Exchange Online.


To get this done you will need:

  • Global Office 365 user admin account
  • Local Exchange Server Administrator account (or account that can perform migration)
Get Started and Migrate Users

To get started, I’ll run the cmdlet below and get my Office 365 user admin credential saved.

$msolcred = get-credential -Message "Enter Exchange Online Admin"

Next, I’ll connect to Exchange Online using the code below.

$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $msolcred -Authentication "Basic" -AllowRedirection

Now, I’ll import the session

Import-PSSession $ExchangeSession

Next, I’ll get my Local Exchange Server admin credential

$exadmin = Get-Credential -Message "Enter Local Exchange Migration Admin"

At this stage, I have all the username and passwords that I need and now I’ll start the migration.

The first line will as for the Alias of the migrated user.

$x = Read-Host "UPN of migrated User"

Now, I’ll start the migration with the line below.

Note: Please change Remote Hostname and Remote Delivery Domain

New-MoveRequest -Identity $x -Remote -RemoteHostName hybrid.yourdomain -TargetDeliveryDomain yourdomain.mail.onmicrosoft.com -RemoteCredential $exadmin -BadItemLimit 1000

To monitor the migration and see status I’ll use the line below:


Get-MoveRequest | Get-MoveRequestStatistics

If you add the switch below, Migration will have to be completed manually