PowerShell.Runspace Property

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Gets or sets the runspace that is used when the pipeline is invoked. The runspace is the operating environment that defines which commands, variables, and other elements are available. This property is introduced in Windows PowerShell 2.0.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

public Runspace Runspace { get; set; }

Property Value

Type: System.Management.Automation.Runspaces.Runspace

A Runspace object that defines the runspace used when the pipeline is invoked. This property can be set to null, in which case a new runspace is created whenever the pipeline is invoked.

Exception Condition
InvalidPowerShellStateException

The PowerShell object cannot be changed in its current state.

ObjectDisposedException

The PowerShell object is disposed.

This property and the RunspacePool property are mutually exclusive; setting one of them resets the other to null.

To invoke the pipeline synchronously, call the Invoke method. To invoke the pipeline asynchronously, call the BeginInvoke method.

For more information on how to use runspaces, see Writing a Windows PowerShell Host Application.

Return to top

Community Additions

ADD
Show: