Public/Start-IAMCoreConnectorSyncJob.ps1

function Start-IAMCoreConnectorSyncJob {
    [CmdletBinding(SupportsShouldProcess = $true)]

    Param(
        [Parameter(ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)]
        [Alias("ConnectorId")]
        [ValidatePattern("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$")]
        [string]$Id,

        [Parameter(Mandatory = $false)]
        [switch]$Wait
    )

    Process {
        if (!$Id) { return; }

        if ($PSCmdlet.ShouldProcess("Connector with ID $Id", "Start sync job")) {   
            # Start the sync job for the specified connector
            Write-Verbose "Starting sync job for connector with ID $Id"
            $SyncJob = New-IAMCoreSyncJob -ConnectorId $Id -JobType ConnectorImport

            if ($SyncJob -and $Wait) {
                Write-Verbose "Waiting for the connector to complete the sync job"
                $SyncJob = $SyncJob | Wait-IAMCoreSyncJob -Verbose:$false
                Write-Verbose "Sync job for connector with ID $Id has completed with the state $($SyncJob.State)"
            }
        
            return $SyncJob
        }
    }
}