Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
April 23, 2024

Scripting with PowerShell Runspaces

A great deal of what we do in PowerShell is based on the use of runspaces. These are are configured containers, not in the Docker sense, that allow us to run PowerShell commands. Normally, we never have to think about them. But they are there. If you open a clean PowerShell session, there is always at least one runspace.

PS C:\> Get-Runspace

 Id Name            ComputerName    Type          State         Availability

 -- ----            ------------    ----          -----         ------------

  1 Runspace1       localhost       Local         Opened        Busy
Fortunately, you don't have to do anything with this. When you run a job command, or `Invoke-Command`, PowerShell will create additional runspaces. Again, you don't have to worry about this. PowerShell will manage the runspaces for you. But what about when you *do* want to work with a custom runspace? Are there any advantages? How do you create a runspace? What can you do with it? These are a few of the questions I want to tackle over the next few articles.
Get a premium subscription for full article and archive access

A great deal of what we do in PowerShell is based on the use of runspaces. These are are configured containers, not in the Docker sense, that allow us to run PowerShell commands. Normally, we never have to think about them. But they are there. If you open a clean PowerShell session, there is always at least one runspace.

PS C:\> Get-Runspace

 Id Name            ComputerName    Type          State         Availability
 -- ----            ------------    ----          -----         ------------
  1 Runspace1       localhost       Local         Opened        Busy

Fortunately, you don't have to do anything with this. When you run a job command, or Invoke-Command, PowerShell will create additional runspaces. Again, you don't have to worry about this. PowerShell will manage the runspaces for you.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.