Migrating mailboxes to 365 using the GUI options or the website can be time consuming, especially if you have hundreds to do. (Of course, if you was doing batches of mailboxes you’d change this PowerShell to import from a file)
The following, connects to your on premise exchange server, and then connects to your 365 tenant and initiates the transfer of the mailbox.
1 2 3 4 5 6 7 8 9 10 11 |
Set-ExecutionPolicy Unrestricted -Force $365ADMIN = Get-Credential $HYBRIDADMIN = Get-Credential $BADITEMLIMIT = 1000 $SESSION = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $365ADMIN -Authentication Basic -AllowRedirection Import-PSSession $SESSION Connect-MsolService -Credential $365ADMIN $UPN = Read-Host "Please enter UPN of the user to migrate to 365" New-MoveRequest -Identity $UPN -Remote -RemoteHostName mail.domain.co.uk -TargetDeliveryDomain tenant.mail.onmicrosoft.com -RemoteCredential $HYBRIDADMIN -BadItemLimit $BADITEMLIMIT |
Note – the on premise exchange server (in my case at least) required credentials in the DOMAIN\USERNAME format, the 365 admin credentials are passed in full UPN format.
Once the above job has been queued, your PowerShell will return to the prompt. If you’d like to get the status of this, or any other move requests currently taking place you can use the Get-MoveRequest commandlet and pipe it to Get-MoveRequestStatistics as per the below
1 |
Get-MoveRequest | Get-MoveRequestStatistics |