Moving Individual Mailboxes to Office 365 via PowerShell

Moving mailboxes from Exchange Hybrid may not always be as straight forward as we want. At times (maybe most of the time) we will use PowerShell (via EMS or the Azure AD Module) to make those moves; whether they be for individual mailboxes or in bulk.

You will want to connect to Office 365 via the Azure AD PowerShell module from the hybrid server.

Connect to Office 365

From the hybrid server, using the ‘Windows Azure Active Directory Module for Windows PowerShell’ console, run the following commands to connect to Office 365.

Set-ExecutionPolicy Unrestricted -Force

 

For the variable $O365CREDS, use your Office 365 global administrator credentials (i.e. globaladmin@domainname.onmicrosoft.com).

$O365CREDS = Get-Credential

 

For the variable $ONPREMCREDS, use your on premise credentials (i.e. AD_DOMAIN_NAME\administrator).

$ONPREMCREDS = Get-Credential
$SESSION = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365CREDS -Authentication Basic -AllowRedirection
Import-PSSession $SESSION
Connect-MsolService -Credential $O365CREDS

 

Move Individual Mailboxes

Run this command to initiate and run the bulk moves…

New-MoveRequest -Identity "INSERT_USER_ALIAS_HERE" -Remote -RemoteHostName hybridserver.domainname.com -TargetDeliveryDomain domainname.mail.onmicrosoft.com -RemoteCredential $ONPREMCREDS -BadItemLimit 1000

 

Monitor Move Requests

To monitor move requests, run this command…

Get-MoveRequest | Get-MoveRequestStatistics

 

To remove move requests, run this command…

Get-MoveRequest | Remove-MoveRequest

 

Have fun!

 

Related Article(s):

 

Reference(s):

Advertisements

5 thoughts on “Moving Individual Mailboxes to Office 365 via PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s