Today I listened to a HanselMinutes podcast about PowerShell 2.0. Scott Hanselman interviewed Hal Rottenberg and Kirk Munro at TechEd 2009.

They talked about RunSpaces in PowerShell 2.0. Can somebody please explain the concept behind them and give some (real-world) use-cases or examples?


4 Answers 4


A Runspace is a specific instance of PowerShell which contains MODIFIABLE collections of commands, providers, variables, functions, and language elements that are available to the command line user (or more generically, to the "host" application).

Generally speaking, Runspaces are a developer topic. If you're on the command-line, you can only modify them by modifying your session, and if you're a typical command-line user, you won't really even be aware of Sessions except when you use them to connect remotely to another computer. However, each session has an associated Runspace (or RunspacePool) that controls what is available to you, and it is possible to create "constrained" runspaces in order to only give users access to certain commands and not others....

In PowerShell 2.0 you use the RunspaceFactory class to create Runspaces or RunspacePool. You can read more about Runspaces on MSDN


A powershell runspace is effectively an isolated instance of the powershell runtime, in my understanding any way.

I have recently had some experiences using PowerShell runspaces inside a web application, to provide some administration features via a web interface. In particular it allowed multiple users to use the application at the same time, without affecting each other.


PowerShell runspace is obsolete term. They use PowerShell session (PSSession) now. I would recommend starting with about_PSSessions help topic.

  • This post has a further bit of blurbage on this: obscure-powershell-tidbits.blogspot.com/2008/12/…
    – squillman
    Commented May 21, 2009 at 13:22
  • 4
    This isn't really true. They renamed the Cmdlets because the Cmdlets were inaccurately named in the first place: they create sessions, which may or may not create a new Runspace ;) But the underlying concept of Runspace and Session hasn't changed.
    – Jaykul
    Commented May 21, 2009 at 14:02

Here are some working examples on using Runspaces and the RunspaceFactory:



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .