liveBook · Manning

Chapter 14: Multitasking with background jobs

What you will learn in chapter 14 of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Introduces PowerShell’s ability to do more than one thing at a time, especially for long-running work involving multiple computers.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces PowerShell’s ability to do more than one thing at a time, especially for long-running work involving multiple computers.

Key terms: multitask, longer-running tasks, multiple target computers

14.1 Making PowerShell do multiple things at the same time

This section explains why ordinary PowerShell commands block the shell and how background jobs let work continue while the shell remains available.

Key terms: single-threaded, background jobs, background thread, background PowerShell process

14.2 Synchronous vs. asynchronous

This section contrasts foreground commands with background jobs, explains the practical limits of running commands asynchronously, and recommends testing commands before backgrounding them.

Key terms: synchronously, asynchronously, background, jobs, input requests, required parameter, errors, cached results, debugged, extension point

14.3 Creating a process job

This section explains how to start a local process job, identify it, and avoid file-path problems when it runs in the background.

Key terms: process job, Start-Job, -ScriptBlock, -FilePath, job object, job name, job ID, -Name, -WorkingDirectory, home directory

14.4 Creating a thread job

This section explains how thread jobs run within the current PowerShell process, when they are useful compared with process jobs, and how their concurrency is limited.

Key terms: thread job, process job, thread, process, throttle limit, -ThrottleLimit, thread jobs, diminishing returns

14.5 Remoting, as a job

This section explains how to run a PowerShell remoting command as a background job across multiple computers.

Key terms: -scriptblock, -command, -throttleLimit, top-level job, PowerShell v6, remoting over SSH, computing workload, results, -JobName

14.6 Jobs in the wild

Shows how a module command can expose a PowerShell job through an -AsJob parameter.

Key terms: -AsJob, New-AzVM, Job, Start-Job, Start-ThreadJob

14.7 Getting job results

This section shows how to check a job’s status, retrieve its results, and decide whether to retain or process them.

Key terms: Get-Job, HasMoreData, job ID, job name, Receive-Job, parent job, child jobs, job output cache, -keep, CLIXML

14.8 Working with child jobs

This section shows how to find a parent job’s child jobs and receive results from an individual child job.

Key terms: parent job, child job, Receive-Job, name, ID

14.9 Commands for managing jobs

This section explains how to remove, stop, or wait for PowerShell jobs and how to inspect failed jobs and their child jobs.

Key terms: Remove-Job, Stop-Job, Wait-Job, job ID, job name, failed job, child jobs, Receive-Job, job status

14.10 Common points of confusion

This section warns against confusing ways of starting background jobs and explains who can see jobs and how long they last.

Key terms: local job, Invoke-Command, -AsJob, jobs, thread jobs, PowerShell process, PowerShell session

14.11 Lab

14.12 Lab answers

Where this is used later

Concepts explained in this chapter

← Chapter 13: Remote control: One-to-one and one-to-many Chapter 15: Working with many objects, one at a time →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.