Connect to Exchange Online and manage migration batches
Connect to Exchange Online
There are a few different ways to connect to Exchange Online via PowerShell and I wanted to document my current process to do so.
First run Windows PowerShell as admin, then
1. Set the execution policy to allow/run scripts
Set-ExecutionPolicy RemoteSigned
or
Set-ExecutionPolicy Unrestricted
2. Prompt for and cache your Office 365 credentials in PowerShell
$Credential=Get-Credential
3. Create a remote PowerShell session with the New-PSSession cmdlet
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
4. Now import the Exchange Online PowerShell cmdlet into the current session
Import-PSSession $Session
You are now connected to Exchange Online and can use below commands to check/complete on migration batches!
Manage migration batches
Personally I mostly only use two PowerShell commands, one to check on all on-going migrations and the other to complete individual mailbox moves.
To view detailed information about the on-going migrations use
Get-MoveRequest | Get-MoveRequestStatistics
To complete and individual mailbox move use
Set-MoveRequest -Identity "Display Name" -CompleteAfter 1
You will need to replace the “Display Name” value with the value from the output of the first command.
If a mailbox comes back with the status “Needs Approval” you can run the following command to trigger completion and ignore any failed or skipped items
Get-MigrationUser -BatchID "Name of Batch" | where dataconsistencyscore -eq Investigate | where status -eq Synced | Set-MigrationUser -ApproveSkippedItems
You will need to replace the “Name of Batch” value with the name of the migration batch you want to run this check and approval on.
Obviously there are many more ways of managing your migration batches and jobs but these are the most common ones I currently use.