Using Runspaces and Runspace pools

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:

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-Job, and Receive-Job. However, the module is far less mature than PoshRSJob and does not include documentation.

When you need a bit more flexibility or efficiency, it's helpful to understand how PowerShell uses these component modules.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.147.53