Public/Add-ConnectorSyncSessionObject.ps1

function Add-ConnectorSyncSessionObject {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        [System.Collections.Hashtable] $Object
    )

    process {
        if ($null -eq $Script:SyncSessionObjects) {
            throw "No active sync session. Please start a sync session before adding objects."
        }

        if ([String]::IsNullOrEmpty($Object.ExternalId)) {
            throw "Object must contain an 'ExternalId' key."
        }

        if ([String]::IsNullOrEmpty($Object.ObjectType)) {
            throw "Object must contain an 'ObjectType' key."
        }

        if ($null -eq $Object.Data -or $Object.Data.GetType().Name -ne "Hashtable") {
            throw "Object must contain a 'Data' key."
        }

        $Script:SyncSessionObjects[$Object.ExternalId] = $Object
    }
}