Synopsis Wait for asynchronous task to complete Syntax Wait-SasAsyncComplete [-job] <Object> [<CommonParameters>] Description This function allows you to wait until the background job with the Cmdlets4Sas scriptblock has finished. Parameters -job <Object> The result from the Invoke-SasAsync commandlet with information about the job Required? true Position? 1 Default value Accept pipeline input? true (ByValue) Accept wildcard characters? false Notes When the job completes and a variable named $SasOutput exists in the background session then the results are copied to $job.SasOutput Examples -------------------------- EXAMPLE 1 -------------------------- C:\PS>$job = Invoke-SasAsync $workspace $sb Wait-SasAsyncComplete $job -------------------------- EXAMPLE 2 -------------------------- C:\PS>$workspace = Connect-SasWorkspaceLocal $ScriptBlock = [scriptblock]{$clone = Copy-SasWorkspace $SasInput; Invoke-SasCode $clone "data _null_; call sleep(1,1); run;"; Disconnect-SasServer $clone; } $job = Invoke-SasAsync $workspace $ScriptBlock $job | Wait-SasAsyncComplete