Public/Add-UserProvisioningSyncSessionObject.ps1

function Add-UserProvisioningSyncSessionObject {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        $Identifier,

        [Parameter(Mandatory = $true)]
        $InputObject
    )

    process {
        if($Script:SyncSessionObjects.ContainsKey($Identifier)) {
            throw [System.ArgumentException]::new("An object with the identifier '$Identifier' has already been added to the sync session")
        }

        if($InputObject.cn -and $InputObject.cn.Length -gt 64) {
            Write-Warning "The 'cn' attribute of the input object exceeds the maximum length of 64 characters and has been automatically shortened by setting it as the identifier ($Identifier)"
            $InputObject.cn = $Identifier
        }
        
        $Script:SyncSessionObjects[$Identifier] = $InputObject
    }
}