Use this when running PowerShell work in the background.
Jobs · PowerShell Automation
PowerShell jobs run commands in the background with Start-Job or -AsJob, checked with Get-Job and collected with Receive-Job, useful for long or parallel tasks.
1. Jobs run work in the background.
2. Collect results with Receive-Job.
3. Check State and errors.
4. Clean up jobs.
5. ThreadJob is lighter.
job started → runs → results received
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
Use Get-Job to inspect state, Wait-Job for completion and Receive-Job -Keep while diagnosing. Inspect child job states and all streams when a parent job is failed or partially complete. Verify any target mutation separately after the job reports completion; the job state alone does not show each workload result is correct.
Step 2 Common mistakes Narrow the fault
- Jobs never received or removed.
Step 3 Where it fails Narrow the fault
A Completed job means its execution container reached completion, not that the business objective was achieved. Parent-session termination can affect access to non-persistent jobs, while remote disconnected scenarios have their own persistence rules. Separate job lifecycle, output retrieval, per-child errors and target-state read-back.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Start-Job runs work in the background.
- Receive-Job collects output.
- Remove jobs when done.
Start-Job { … }; Get-Job; Receive-Job <id>— background jobsInvoke-Command -AsJob -ComputerName <list>— remote jobsRemove-Job -State Completed— cleanup
ReferenceWhy it matters1 section · depth on demand
In depth
PowerShell jobs run commands in the background while the session continues, useful for long tasks or running several tasks at once. Thread jobs are lighter and faster than classic process-based background jobs.
| Command | Runs in |
|---|---|
Start-Job | Separate process (heavy, isolated) |
Start-ThreadJob | Thread in the same process (fast) |
Invoke-Command -AsJob | Remote machines |
ForEach-Object -Parallel | Runspaces (PowerShell 7) |
$jobs = 'srv01','srv02','srv03' | ForEach-Object {
Start-ThreadJob -ArgumentList $_ { param($s) Test-Connection $s -Count 2 -Quiet }
}
$jobs | Wait-Job -Timeout 60 | Receive-Job
$jobs | Remove-Job -Force
Always collect results with Receive-Job and clean up with Remove-Job; errors inside jobs are only visible when receiving them.
ReferenceImportant terms & boundaries1 section · depth on demand
PowerShell mechanics
PowerShell jobs decouple command execution from the interactive pipeline. BackgroundJob runs work in a separate local process, RemoteJob represents remote execution, and ThreadJob/PSTaskJob runs in another thread/runspace in the same process. Job objects have lifecycle state plus buffered data streams; completion of the job container and retrieval of output with Receive-Job are separate operations.
ReferenceConfiguration & state1 section · depth on demand
Authoring and lifecycle
Choose job type according to isolation, serialization and overhead needs. Track job identifiers and child jobs, set explicit throttling outside the job layer where needed, and decide whether output must persist after the parent session exits. Receive and archive relevant streams before removal, because job repositories and parent-session lifetime affect what remains accessible.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Configuration & expected output
Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.
Configuration example
Assumptions: Review target identity, permissions and environment before mutation.
$job = Start-Job { Get-Date }
$job | Wait-Job | Receive-JobVerification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Microsoft Learn documentation reviewed for bounded PowerShell reference claims. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_jobs?view=powershell-7.6 · confidence 94%Quick lookup tables
Jobs · PowerShell operational reference
Topic-specific PowerShell runtime identity, persistence, verification, output and failure-boundary lookup.
| Boundary | Jobs reference |
|---|---|
| Runtime identity | PowerShell edition/version + command/module source |
| Persistent intent | Script/module/config prerequisites under source control |
| Verification | Read-only discovery → execution evidence → independent target read-back |
| Output contract | Structured objects/streams before formatting |
| Failure boundary | Separate engine/binding from transport/API/native and target-state failures |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Job output can be buffered until received and remote/background jobs can serialize objects. Multiple child jobs can finish in different orders, and a parent can aggregate mixed states. Inspect error and output streams per child when correlation matters instead of relying only on the parent status line.