Runspaces and Runspace pools are an efficient way of asynchronously executing PowerShell code. Runspaces are far more efficient than jobs as they execute in the same process. The main disadvantage is complexity: PowerShell does not include native commands to simplify working with these classes.
Fortunately, PowerShell is highly extensible. Two third-party modules have been created to work with Runspaces:
- PoshRSJob: https://www.powershellgallery.com/packages/PoshRSJob
- ThreadJob: https://www.powershellgallery.com/packages/ThreadJob
Both modules work with Windows PowerShell and PowerShell Core.
The PoshRSJob module is very mature and has a rich set of features. It is the most frequently recommended module, providing an alternative to the Start-Job command.
ThreadJob has promise; it interacts with the existing job commands, such as Get-Job, Wait...