A job is an asynchronous PowerShell operation that runs work as a background process, allowing the interactive command flow to continue while the work proceeds. section 6.1.2
Use jobs when a command lacks a no-wait option or when several operations should run concurrently:
- Start each operation with Start-Job and its own script block. section 6.1.2
- Track completion with Get-Job and pause the workflow with Wait-Job. section 6.1.2
- Retrieve command results with Receive-Job after the jobs finish. section 6.1.2
Parallel downloads
Start two Invoke-WebRequest commands as separate jobs, wait for both downloads to complete, and then continue the script. section 6.1.2
Start-Job -ScriptBlock {
Invoke-WebRequest -Uri $UrlA -OutFile $FileA
}
Start-Job -ScriptBlock {
Invoke-WebRequest -Uri $UrlB -OutFile $FileB
}
Get-Job | Wait-Job
Shows the compact job workflow for launching two downloads and waiting for completion. section 6.1.2
