How to do Hard Match- Part 2 ?

In my previous post I wrote about how we can do Hard Match of objects in on-premise to the corresponding objects in the cloud through Dirsync.

In this post we will be looking into a simple way to generate Immutable ID that we used in Hard Match process.

Connect to the machine where we have AD installed. Open a cmd prompt with administrator credentials and run the below command

ldifde -f export.txt -r "(Userprincipalname=*)" -l "objectGuid, userPrincipalName"



This command will give us an output file  export.txt that has all the user principal names and Immutable IDs of all objects that has UPN.

The output looks like this for each object

dn: CN=2013 OU=DirSynced OU DC=prakum DC=msftonlinerepro DC=com 
changetype: add     
objectGUID:: g8Pclm4vok+vFWtMERklmg==     


Now whichever object we want to do a hard match we just have to search for the object using UPN in the above text file and note down the corresponding objectGUID for that object.

We can use the objectGUID in the below command to set the immutable ID in the cloud for the object as below

Set-MsolUser -UserPrincipalName -ImmutableId g8Pclm4vok+vFWtMERklmg==  

Here is the UPN of the user who is in cloud and we want to sync the on-premise user to sync to.


Run Dirsync

Now force an Dirsync to connect the users 


Note: Due to replication and delay in onprem and cloud we might have to wait for some time and force Dirsync couple of times.

Comments (8)

  1. Anonymous says:

    There are 2 types of matching we do during Dirsync

    Soft Match
    Hard Match

    In this post

  2. Hiten Giri says:

    Hi Praveen. Are you MSFT? I am trying to find you GAL but can find you.

    1. Hello Hiten

      My email is IM me if you feel I can help you with something.
      My personal email address is

      Praveen Kumar

  3. Hiten Giri says:

    Hi Praveen. Are you MSFT? I am trying to find you GAL but can find you.

  4. I have a user where the immutable IDs match, however, I cannot get Dirsync to process this user.

    The user still has a status of ‘In cloud’ rather than ‘Synced with Active Directory’

    $guid = (get-Aduser myuser).ObjectGuid
    $immutableID = [System.Convert]::ToBase64String($guid.tobytearray())
    Write-Host $immutableID
    Get-MsolUser -UserPrincipalName "myuserUPN" | select ImmutableId, LastDirSyncTime


    ImmutableId LastDirSyncTime
    ———– —————

    How do I get the sync process to work for this user.

    Greg Farquhar

  5. Jayson says:

    Same issue for me as Greg – been trying to solve with both soft and hard match with Microsoft O365 support now for about 3 weeks – any more help would be appreciated!

  6. Paul Steele says:

    Same thing here. Anyone ever find a solution for this?

  7. Anon says:

    Hello, How do you get this to work for all users? What would be the command to do this?

Skip to main content