Lerch Web Wiki

Random, erratic, no responsibility is taken for the correctness of this information

User Tools

Site Tools


powershell:basics:jobs

Jobs

Job-OutputSamples.ps1
$job = start-job { $(Write-Verbose "Verbose 1" -verbose; 1..10 | 
  % { "Output $_" }; Write-Verbose "Verbose 2" -verbose) *>&1 } 
 
$job | Wait-Job
 
# Verbose data is part of the job output stream now.
$results = $job.ChildJobs[0].Output
Write-Output $results
 
# Can also retrieve from Receive-Job
$results = Receive-Job $job -Keep
Write-Output $results
Run-SBinJob.ps1
$sb = { if ($PSCommandPath) {Write-Output ('running direct')} else {Write-Output 'running as job'}}
&$sb
$job = Start-Job -ScriptBlock $sb
$job | Wait-Job
$job | Receive-Job
powershell/basics/jobs.txt · Last modified: 2017/02/21 11:05 by marcus