The two functions below can be used to convert between immutable ID and AD object. 

The default immutable ID value used by AADConnect is the encoded ObjetGuid attribute of the user or object in the on-premises directory. There are a few helpful scripts around that will convert your immutable ID to Object Guid however in my usage, I typically just want to grab the immutable ID from a user object or grab the user object from the immutable ID. The functions below perform these tasks and also make use of the pipeline so that they can be seamlessly integrated into your workflow.

 

PowerShell
Edit|Remove
function get-ImmutableIDfromADObject 
{ 
    [CmdletBinding()] Param( 
        [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]$ADObject)  
   process{  
        if (!$ADObject.objectguid){$ADObject = get-adobject $AdObject -properties objectGuid} 
        [system.convert]::ToBase64String($ADObject.objectguid.tobytearray()) 
    } 
} 
 
function get-ADObjectFromImmutableID{ 
      [CmdletBinding()] Param( 
        [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)][string]$ImmutableID) 
   process { get-adobject  ([guid]([system.convert]::FromBase64String($ImmutableID)))} 
} 
 
<# 
get-aduser shane.wright | get-ImmutableIDfromADObject 
6WuADX7LfUa8DVAQGxuZcA== 
 
get-aduser shane.wright | get-ImmutableIDfromADObject | get-ADObjectFromImmutableID 
 
DistinguishedName                          Name         ObjectClass ObjectGUID                           
-----------------                          ----         ----------- ----------                           
CN=Shane Wright,OU=Staff,DC=contoso,DC=com Shane Wright user        0d806be9-cb7e-467d-bc0d-50101b1b9970 
 
 
get-ADObjectFromImmutableID 6WuADX7LfUa8DVAQGxuZcA== 
DistinguishedName                          Name         ObjectClass ObjectGUID                           
-----------------                          ----         ----------- ----------                           
CN=Shane Wright,OU=Staff,DC=contoso,DC=com Shane Wright user        0d806be9-cb7e-467d-bc0d-50101b1b9970 
#>