February 2019
Intermediate to advanced
626 pages
15h 51m
English
Receive-Job is used to retrieve data from a job. Receive-Job may be both as a script runs and when the script is finished. If Receive-Job is run before a job is finished, any existing values will be returned. Running Receive-Job again will get any new values that have been added, not previously filesystem, which retrieved values. This is shown in the following example:
PS> $job = Start-Job { 1..10 | ForEach-Object { $_; Start-Sleep -Seconds 2 } }>> Write-Host 'Sleeping 2'>> Start-Sleep -Seconds 2>> $job | Receive-Job>> Write-Host 'Sleeping 5'>> Start-Sleep -Seconds 5>> $job | Receive-JobSleeping 21Sleeping 5234
The remaining results will be available to Receive-Job as they are returned, or when the job has completed. ...
Read now
Unlock full access