Migrate Exchange Mailbox to Exchange Online with PowerShell

In this blog post, Show you ways to migrate a user mailbox during a hybrid Configuration to Exchange Online using PowerShell.

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

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

To get this done you’ll need:

Global Office 365 user admin account
Local Exchange Server Administrator account (or account which will perform migration)

Get Started and Migrate Users

To get started, Run the cmdlet below and obtain my Office 365 user admin credential saved.

$msolcred = get-credential -Message “Enter Exchange Online Admin”

Next, Hook up with 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, Import the session

Import-PSSession $ExchangeSession

Next, Get my Local Exchange Server admin credential

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

At this stage, I even have all the username and passwords that i want 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, Start the migration with the road below.

Note: Please change Remote Hostname & 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 road below:

Get-MoveRequest

Get-MoveRequest | Get-MoveRequestStatistics

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

avertWhenReadyToComplete