Migration of mailboxes

Script – Migration of mailboxes from Exchange On-premise to Exchange Online

If you want to perform a bulk migration of mailboxes from Exchange On-premise to Exchange Online, this PowerShell script will help you.

You just need to create a txt file with the alias mailboxes that you want to migrate. The script will migrate all the alias mailboxes on the txt to Office 365 (Exchange Online).

This is tested on an Exchange 2010 Hybrid environment but should work also on the new Exchange version.

Script localization: https://gallery.technet.microsoft.com/office/Script-Migration-of-0f2aa80d 

 

PowerShell
#********************************************************************************************* 
 
# Migration of mailboxes from Exchange On-premise to Exchange Online 
# 
# Written by João Dias  
# Date 28/03/2017 
# 
# Version: 1.0 
# 
#********************************************************************************************* 
 
#Set Powershell Execution Policy to Unrestricted 
Set-ExecutionPolicy Unrestricted -Force 
 
#Get credentials 
$O365CREDS = Get-Credential 
$ONPREMCREDS = Get-Credential 
 
#Configuring Session 
$SESSION = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365CREDS -Authentication Basic -AllowRedirection 
 
#Import Exchange Online Session 
Import-PSSession $SESSION 
 
#Connect to Exchange Online 
Connect-MsolService -Credential $O365CREDS 
 
#Reading the user list that will be migrated to O365 
$MAILBOXLIST = Get-Content "C:\temp\Userlist.txt" 
 
#Migration of mailboxes to O365 
foreach ($line in $MAILBOXLIST) {New-MoveRequest -Identity $line.alias -Remote -RemoteHostName niras.dk -TargetDeliveryDomain niras.mail.onmicrosoft.com -RemoteCredential $ONPREMCREDS -BadItemLimit 1000}