I have been writting script for onboarding and I have faced some issue, involving ImmutableID. the ImmutableID is the unique identifier create by your directory synchronization. it s a conversion of the ObjectGUID Attribute of your object.
So please find how to calculate the immutableID based:
First I you have to retreive the Object GUID using :
$User = Get-ADuser $UserSamAccount -Properties * -server $DC
$ImmutableID = [system.convert]::ToBase64String(([GUID]($User.ObjectGUID)).tobytearray())