PowerShell PowerShell Background Jobs Basic job management


Example

Get a list of all jobs in the current session:

Get-Job

Waiting on a job to finish before getting the result:

$job | Wait-job | Receive-Job 

Timeout a job if it runs too long (10 seconds in this example)

$job | Wait-job -Timeout 10

Stopping a job (completes all tasks that are pending in that job queue before ending):

$job | Stop-Job 

Remove job from current session's background jobs list:

$job | Remove-Job

Note: The following will only work on Workflow Jobs.

Suspend a Workflow Job (Pause):

$job | Suspend-Job 

Resume a Workflow Job:

$job | Resume-Job