liveBook · Manning

Child job

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

A child job is an individual background job associated with a parent job, such as one created for a separate target or execution unit.

A child job is an individual background job beneath a parent job. A PowerShell job normally has at least one child job, even when the work runs locally. section 14.8 section 14.3

Use child jobs when you need to inspect results or failures separately:

  • List a parent's children with Get-Job -id 1 | Select-Object -ExpandProperty ChildJobs. section 14.8
  • Retrieve one child job by name or ID with Receive-Job. section 14.8
  • Check children separately when a multi-target job fails; each child can report a different error. section 14.9
PS /Users/travisp> get-job -id 1 | format-list *
State         : Completed
HasMoreData   : True
StatusMessage :
Location      : localhost
Command       :  dir
JobStateInfo  : Completed
Finished      : System.Threading.ManualResetEvent
InstanceId    : e1ddde9e-81e7-4b18-93c4-4c1d2a5c372c
Id            : 1
Name          : Job1
ChildJobs     : {Job2}
PSBeginTime   : 12/27/2019 2:34:25 PM
PSEndTime     : 12/27/2019 2:34:29 PM
PSJobTypeName : BackgroundJob
Output        : {}
Error         : {}
Progress      : {}
Verbose       : {}
Debug         : {}
Warning       : {}
Information   : {}

Inspect the parent and child properties side by side to see their IDs, states, commands, locations, and cached output. section 14.8

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains hierarchy, listing, result retrieval, and per-child failures, but does not develop child-job internals.
Examples
Demonstrates local directory listings and remote commands that produce separately inspectable child jobs.
What it assumes
Assumes familiarity with starting and querying PowerShell background jobs, while introducing the ChildJobs property and child-job retrieval.
What you can do after
Diagnose individual job results and failures by listing, selecting, and receiving child jobs.
How it connects
Connects child jobs with background jobs, parent jobs, Get-Job, Receive-Job, remoting, and job results.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.