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
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
powershell/basics/jobs.txt · Last modified: 2017/02/21 11:05 by marcus