skip to Main Content

Move mailbox to Exchange Online with PowerShell

After installing the Hybrid Configuration Wizard (HCW), you like to move a mailbox to Exchange Online with PowerShell. The term is also known as onboarding a mailbox to the cloud. So what do you need to fill in PowerShell to start the mailbox migration? In this article, you will learn how to migrate a mailbox to Exchange Online with PowerShell.

How to move mailbox to Exchange Online with PowerShell

To move a mailbox to Exchange Online with PowerShell, follow these steps:

1. Connect to Exchange Online PowerShell

Start PowerShell as administrator and Connect to Exchange Online PowerShell.

PS C:\> Connect-ExchangeOnline

Note: You are not pushing the on-premises mailbox to Exchange Online. In fact, you are pulling the on-premises mailbox from Exchange Online. That’s why you need to connect to Exchange Online and run the commands from Exchange Online PowerShell.

2. Find migration endpoint remote server URL

Get the remote server URL by using the Get-MigrationEndpoint cmdlet. Read more about how to find RemoteHostName URL for mailbox migration. The Hybrid Configuration Wizard created this migration endpoint.

Copy the RemoteServer URL value as you need it in the next part.

PS C:\> Get-MigrationEndpoint | Format-List Identity, RemoteServer


Identity     : Hybrid Migration Endpoint - EWS (Default Web Site)
RemoteServer : d07c851a-d141-2c91-f2b3-4bb87r5e51gg.resource.mailboxmigration.his.msappproxy.net

3. Move mailbox to Exchange Online with PowerShell

Create a new move request to move the primary mailbox and archive mailbox to Exchange Online. Fill in the following details:

  • -Identity: Mailbox name or email address
  • -RemoteHostName: The remote server that you copied in the previous step
  • -TargetDeliveryDomain: Primary SMTP domain used for the Exchange Online organization mailboxes
  • -RemoteCredential: On-premises administrator account with privileges

After running the cmdlet, a credential sign-in request will show up. Fill in the password of the on-premises credentials (RemoteCredential).

PS C:\> New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "d07c851a-d141-2c91-f2b3-4bb87r5e51gg.resource.mailboxmigration.his.msappproxy.net" -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential exoip\administrator)

DisplayName Status TargetDatabase
----------- ------ --------------
Maisha Lee  Queued EURP190DG009-db121

4. Move primary mailbox only to Exchange Online with PowerShell

Suppose the archive mailbox location is in Exchange Online and the primary mailbox location is in Exchange on-premises. When you run the above command, you receive the following error message:

You must specify the PrimaryOnly parameter
Target user ‘Maisha Lee’ already has an archive mailbox.

This is how it looks in the PowerShell console:

PS C:\> New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "d07c851a-d141-2c91-f2b3-4bb87r5e51gg.resource.mailboxmigration.his.msappproxy.net" -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential exoip\administrator)
You must specify the PrimaryOnly parameter.
Target user 'Maisha Lee' already has an archive mailbox.
    + CategoryInfo          : NotSpecified: (:) [New-MoveRequest], MailboxReplicationPermanentException
    + FullyQualifiedErrorId : [Server=PAXP190MB1743,RequestId=3f8179c3-aa93-453f-9e14-d824968f34c4,TimeStamp=5/28/2022
    7:19:13 AM] [FailureCategory=Cmdlet-MailboxReplicationPermanentException] FE8B9422,Microsoft.Exchange.Management.
  Migration.MailboxReplication.MoveRequest.NewModernMoveRequest
    + PSComputerName        : outlook.office365.com

You must add the -PrimaryOnly parameter to the command.

Create a new move request to move the primary mailbox only to Exchange Online. Fill in the following details:

  • -Identity: Mailbox name or email address
  • -RemoteHostName: The remote server that you copied in the previous step
  • -PrimaryOnly: Keep value empty
  • -TargetDeliveryDomain: Primary SMTP domain used for the Exchange Online organization mailboxes
  • -RemoteCredential: On-premises administrator account with privileges

After running the cmdlet, a credential sign-in request will show up. Fill in the password of the on-premises credentials (RemoteCredential).

PS C:\> New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "d07c851a-d141-2c91-f2b3-4bb87r5e51gg.resource.mailboxmigration.his.msappproxy.net" -PrimaryOnly -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential exoip\administrator)

DisplayName Status TargetDatabase
----------- ------ --------------
Maisha Lee  Queued EURP190DG047-db049

5. Get mailbox move status

Get the status of the mailbox move request by using the Get-MoveRequest cmdlet.

PS C:\> Get-MoveRequest -Identity "Maisha.Lee@exoip.com" | Get-MoveRequestStatistics

DisplayName StatusDetail TotalMailboxSize            TotalArchiveSize PercentComplete
----------- ------------ ----------------            ---------------- ---------------
Maisha Lee  Completed    32.11 MB (33,670,771 bytes) 0 B (0 bytes)    100

The mailbox will complete.

If that is not the case and you can’t complete the mailbox move request, you can suspend and resume the move request. It helps in most situations when you get a failed status. For example, the status detail TransientFailure.

Did this article help you to migrate the mailbox to Exchange Online with PowerShell? I hope it did.

Read more: Complete migration batch with PowerShell »

Conclusion

You learned how to move a mailbox to Exchange Online with PowerShell. Connect to Exchange Online PowerShell and run the cmdlet as shown in the article. Keep an eye out if the mailbox move to Exchange Online successfully completed.

Did you enjoy this article? You may also like Target mailbox doesn’t have an SMTP proxy matching. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has One Comment

Leave a Reply

Your email address will not be published.