I recently was working on an issue where an OnPremises Exchange Mailbox couldnĀ“t be moved into Exchange Online (aka Office 365) via New-MoveRequest. The error message was “Target user ‘XYZ’ already has a primary mailbox”. The solution to fix that was quite easy
The full error :
PS C:\Users\wieczorek.5> New-MoveRequest -Remote -RemoteHostName hybrid.emea.contoso.com -TargetDelivery
Domain contoso.onmicrosoft.com -RemoteCredential $ONPREMCREDS -Identity contoso.test
Target user 'Contoso Testuser' already has a primary mailbox.
Ā Ā Ā + CategoryInfoĀ Ā Ā Ā Ā Ā Ā Ā Ā : InvalidArgument: (contoso.test:MailboxOrMailUserIdParameter) [New-MoveRequest], Targ
Ā Ā etUserAlrea...ailboxException
Ā Ā Ā + FullyQualifiedErrorId : [Server=AM4PR05MB3379,RequestId=0a954782-664b-401f-a9dc-7f54743f9dce,TimeStamp=06.07.201
Ā Ā 8 21:49:32] [FailureCategory=Cmdlet-TargetUserAlreadyHasPrimaryMailboxException] C8F1378D,Microsoft.Exchange.Manag
Ā ement.Migration.MailboxReplication.MoveRequest.NewMoveRequest
Ā Ā Ā + PSComputerNameĀ Ā Ā Ā Ā Ā Ā : outlook.office365.com
Root cause:
The root cause here was that somebody enabled the Exchange Online feature and then created the Exchange OnPremises mailbox. This caused that the user had two mailboxes. One in the cloud, the other one in Exchange Online.
Solution:
1.) As this user never used any office 365 features and didnĀ“t got any emails in the cloud I decided to fully delete him in the cloud via:
remove-MSOLUser -UserPrincipalName contoso.test@contoso.com
and then
remove-MSOLUser -UserPrincipalName contoso.test@contoso.com -RemoveFromRecycleBin
Keep noted the user might lose data if he had something already stored in the cloud if you perform these steps!
2.) After a short time I run a full (DirSync) sync
3.) Once the user is back synced from the OnPremises Active Directory I assigned him again an Office 365 license with an Exchange Online feature.
4.) After that I was able to perform the move via New-MoveRequest