Step 7: Migration using PowerShell

May 30, 2018 | by iaur | posted as Hybrid(EXO), M365 Migration

  • Connect to EXO management shell and MSOL server
Set-ExecutionPolicy Unrestricted -Force

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

$O365CREDS = Get-Credential
Administrator: Windows PowerShell 
PS 
PS 
PS 
cmdlet Get-credential 
Supply values for the 
r edential 
'1 n ons PowerS e 
opyright (C) 2014 Mi crosoft Corporation. All rights reserved. 
adm 
Set-Executionpolicy Unrestricted -Force 
S0365CREDS = Get-credential 
at convnand pipeline position I 
following parameters: 
Windows PowerShell credential req 
Enter your credenbals. 
Password: 
in@faceresionem.onm v

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

$ONPREMCREDS = Get-Credential
Administrator: Windows PowerShell 
Sin ons PowerS e 
opyright (C) 2014 Microsoft Corporation. All rights reserved. 
PS 
PS 
PS 
cmdlet Get-credential 
Supply values for the 
r edential 
PS 
PS 
PS 
cmdlet Get-credential 
Supply values for the 
r edential 
Set-Executionpolicy Unrestricted -Force 
S0365CREDS = Get-credential 
at convnand pipeline position I 
following parameters: 
SONPREMCREDS = Get-credential 
at convnand pipeline position I 
following parameters: 
Windows PowerShell credential req 
Enter your credenbals. 
Password:
$SESSION = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365CREDS -Authentication Basic -AllowRedirection
Import-PSSession $SESSION
Connect-MsolService -Credential $O365CREDS
  • Run the cmdlets below

Move Individual Mailboxes

Run this command to initiate and run the bulk moves…

New-MoveRequest -Identity “EMAIL_ADDRESS” -Remote -RemoteHostName MAIL.DOMAIN.COM -TargetDeliveryDomain DOMAIN.mail.onmicrosoft.com -RemoteCredential $ONPREMCREDS -BadItemLimit 1000

Note: autocomplete migration batch

New-MoveRequest -Identity “EMAIL_ADDRESS” -Remote -RemoteHostName MAIL.DOMAIN.COM  -TargetDeliveryDomain DOMAIN.mail.onmicrosoft.com -RemoteCredential $ONPREMCREDS -BadItemLimit 1000 -BatchName “BATCH_NAME

Note: add batch name

New-MoveRequest -Identity “EMAIL_ADDRESS” -Remote -RemoteHostName MAIL.DOMAIN.COM -TargetDeliveryDomain DOMAIN.mail.onmicrosoft.com -RemoteCredential $ONPREMCREDS -SuspendWhenReadyToComplete -BadItemLimit 1000 -BatchName “BATCH_NAME

Note: not autocomplete migration batch

PS New-MoveRequest -Identity -Remote -RemoteHostName mail . faceresionen. 
z -TargetDeIiveryDomain faceresionem.mail.onmicrosoft.com -RenoteCredentiaI SONPREMCREDS -SuspendWhenReadyToCompIete -8 
adltemLimit 1000 -SatchName 
ARNING: When an item can 't be read from the source database or it can't be written to the destination database, it 
ill be considered corrupted. By specifying a non-zero 8adItemLimit, you are requesting Exchange not copy such items to 
the destination mailbox. At move completion, these corrupted itens will not be available at the destination mailbox. 
Di spl ayName 
Hyb User I 
PS 
Status Detai - 
Wait i ngFor JobPi ckup 
TotalMai boxSi ze 
2.479 MB by... 
Total Ar chi vesi ze 
Per centCompI ete

Monitor Move Requests

To monitor move requests, run this command…

 Get-MigrationUser | Get-MigrationUserStatistics
Get-MoveRequest | Get-MoveRequestStatistics
PS 
Di spl ayName 
Hyb User I 
PS 
Get-MoveRequest I 
Status Detai - 
AutoSuspended 
Get -MoveRequ est St ati sti cs 
TotalMai boxSi ze 
2.479 MB by... 
Total Ar chi vesi ze 
0 8 (O bytes) 
Per centCompI ete
  • Once the status turned to AutoSuspended and if your user has new emails coming you may run the Resume-MoveRequest

for the user or if you want to stop the move request you can user the Suspend-MoveRequest cmdlets

Suspend-MoveRequest -Identity “EMAIL_ADDRESS
Resume-MoveRequest -Identity “EMAIL_ADDRESS

*using Resume-MoveRequest, the batch will be autocompleted hence the user will now be an O365 mailbox

Resume-MoveRequest -Identity “EMAIL_ADDRESS” -SuspendWhenReadyToComplete
S Get-MoveRequest I 
•i spl ayName 
Yb User I 
Status Detai - 
AutoSuspended 
Get -MoveRequ estStati sti cs 
TotalMai boxSi ze 
2.479 MB by... 
Total Ar chi vesi ze 
0 8 (O bytes) 
Per centCompI ete
Administrator: Windows PowerShell 
Resume-MoveRequest -Identity "hyb_user3@faceresionem.xyz" 
PS 
PS 
Get-MoveRequest I Get-MoveRequestStatisti 
Get-MoveRequest I Get-MoveRequestStatistics 
Get-MoveRequest I Get-MoveRequestStatistics 
Get-MoveRequest I Get-MoveRequestStatistics 
Get-MoveRequest I Get-MoveRequestStatistics 
Get-MoveRequest I Get-MoveRequestStatistics 
Di spl ayName 
Hyb User 3 
Hyb User 2 
PS 
Di spl ayName 
Hyb User 3 
Hyb User 2 
PS 
Di spl ayName 
Hyb User 3 
Hyb User 2 
PS 
Di spl ayName 
Hyb User 3 
Hyb User 2 
PS 
Di spl ayName 
Hyb User 3 
Hyb User 2 
PS 
Di spl ayName 
Hyb User 2 
Hyb User 3 
PS 
Status Detai - 
AutoSuspended 
Comp et ed 
Status Detai - 
Initial Seeding 
Comp et ed 
Status Detai - 
Incremental Sync 
Comp et ed 
Status Detai - 
Incr anent al Sync 
Comp et ed 
Status Detai - 
CopyDataFi n al Sync 
Comp et ed 
Status Detai - 
Compl et ed 
Comp I et ed 
TotalMai boxSi ze 
3.241 MB by... 
7. 679 MB by... 
TotalMai boxSi ze 
3.241 MB by... 
7. 679 MB by... 
TotalMai boxSi ze 
3.241 MB by... 
7. 679 MB by... 
TotalMai boxSi ze 
3.241 MB by... 
7. 679 MB by... 
TotalMai boxSi ze 
3.241 MB by... 
7. 679 MB by... 
Total Mai boxSi ze 
7.679 MS by... 
3.241 MB by... 
Total Ar chi vesi ze 
0 8 (O bytes) 
0 8 (O bytes) 
Total Ar chi vesi ze 
0 8 (O bytes) 
0 8 (O bytes) 
Total Ar chi vesi ze 
0 8 (O bytes) 
0 8 (O bytes) 
Total Ar chi vesi ze 
0 8 (O bytes) 
0 8 (O bytes) 
Total Ar chi vesi ze 
0 8 (O bytes) 
0 8 (O bytes) 
Total Ar chi vesi ze 
0 8 (O bytes) 
0 8 (O bytes) 
Per centCompI ete 
Per centCompI ete 
Per centCompI ete 
Per centCompI ete 
Per centCompI ete 
Per centCompI ete

Other statistics cmdlets:

Get-MigrationUserStatistics -Identity davidp@corp.contoso.com -IncludeReport | FL Status,Error,Report
 Get-MigrationUser | Get-MigrationUserStatistics  -IncludeReport | FL Status,Error,Report
Get-MoveRequest | Get-MoveRequestStatistics | FL identity, percentcomplete
Get-moverequest | get-moverequeststatistics | Where-Object {$_.PercentComplete -lt 100} | FL identity, percentcomplete
Get-MoveRequestStatistics -Identity user@domain.com -IncludeReport | Export-CSV C:\MRStats.csv