Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 14 down vote accepted

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

share|improve this answer

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.

share|improve this answer

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

share|improve this answer
This post has a further bit of blurbage on this:… – squillman May 21 '09 at 13:22
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 May 21 '09 at 14:02
Ah. Thanks for that. – squillman May 21 '09 at 14:06

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


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.