Chapter 13. PowerShell Jobs
This chapter covers
- Asynchronous processing
- PowerShell jobs
- Job cmdlets
- Job types
- Workflow jobs
- Scheduled jobs
Exit pursued by a bear
—William Shakespeare Stage directions from The Winter’s Tale
So far, most of the techniques we’ve shown you have been synchronous, meaning you type in the command—be it a cmdlet, script, or function—and wait for the results. The results are back in a few seconds at most, usually far quicker. Synchronous execution is perfect for ad hoc, interactive working, but what about when you’re executing a long-running process against many remote machines that could take hours to run? Waiting for those to finish locks you out of further work in that console. You could open additional instances of PowerShell or you could run the tasks asynchronously.
An asynchronous task is one that’s started and left to run to completion in the background as you carry on working at other tasks. Asynchronous execution is supplied to PowerShell by using PowerShell jobs.
Note
In PowerShell v2, PowerShell jobs depended heavily on PowerShell remoting. Those dependencies were removed in PowerShell v3.