How to merge on-prem Users to Cloud-only User
Sometimes, you need to merge an on-premises user with a cloud-only user. This situation often arises in small or medium-sized companies. They may have initially adopted cloud services, such as mailboxes and SharePoint, while continuing to use on-premises Active Directory (AD) for local staff. However, without setting up a hybrid environment, they end up with two separate user accounts.
In this post, I will show you how to merge an on-premises user with a cloud-only user.
On-prem User
1
2
3
4
5
6
7
$onpremUser = "testuser"
$guid =(Get-ADUser $ADUser).Objectguid
$immutableID=[system.convert]::ToBase64String($guid.tobytearray())
$immutableID
So we have the immutableID of the on-prem user. Next to set it to the cloud user.
Cloud User
1
2
3
4
5
Connect-AzureAD
$cloudUser = "otheruser@domain.com"
$aaduser = Get-AzureADUser | ?{$_.UserPrincipalName -like $cloudUser}
Merge the users
1
Set-AzureADUser -ObjectId $aaduser.ObjectId -ImmutableId $immutableID
This post is licensed under CC BY 4.0 by the author.