Runspace Class

Definition

Public interface to Msh Runtime. Provides APIs for creating pipelines, access session state etc.

public abstract class Runspace : IDisposable
Inheritance
Runspace
Implements

Properties

ApartmentState

ApartmentState of the thread used to execute commands within this Runspace

CanUseDefaultRunspace
ConnectionInfo

Connection information for remote Runspaces, null for local Runspaces

Debugger

Gets the debugger

DefaultRunspace

Gets and sets the default Runspace used to evaluate scripts

DisconnectedOn
Events

Gets the event manager

ExpiresOn
Id
InitialSessionState

InitialSessionState information for this runspace.

InstanceId

Get unqiue id for this instance of runspace. It is primarily used for logging purposes

JobManager

Manager for JobSourceAdapters registered in this runspace.

Name
OriginalConnectionInfo

ConnectionInfo originally supplied by the user

RunspaceAvailability

Gets the current availability of the Runspace

RunspaceConfiguration

RunspaceConfiguration information for this runspace.

RunspaceIsRemote
RunspaceStateInfo

Retrieve information about current state of the runspace

SessionStateProxy

Gets session state proxy

ThreadOptions

This property determines whether a new thread is create for each invocation

Version

Return version of this runspace

Methods

ClearBaseTransaction()

Clears the transaction set by SetBaseTransaction()

Close()

Close the runspace synchronously.

CloseAsync()

Close the runspace Asynchronously.

Connect()

Connects the runspace to its remote counterpart synchronously.

ConnectAsync()

Connects a runspace to its remote counterpart asynchronously.

CreateDisconnectedPipeline()

Creates a PipeLine object in the disconnected state for the currently disconnected remote running command associated with this runspace.

CreateDisconnectedPowerShell()

Creates a PowerShell object in the disconnected state for the currently disconnected remote running command associated with this runspace.

CreateNestedPipeline(String, Boolean)

Creates a nested pipeline.

CreateNestedPipeline()

Creates a nested pipeline.

CreatePipeline()

Create an empty pipeline

CreatePipeline(String)

Creates a pipeline for specified command string

CreatePipeline(String, Boolean)

Create a pipeline from a command string.

Disconnect()

Disconnects the runspace synchronously.

DisconnectAsync()

Disconnects the runspace asynchronously.

Dispose()

Disposes this runspace instance. Dispose will close the runspace if not closed already.

Dispose(Boolean)

Protected dispose which can be overridden by derived classes.

GetApplicationPrivateData()

Private data to be used by applications built on top of PowerShell.

        Local runspace is created with application private data set to an empty <xref href="System.Management.Automation.PSPrimitiveDictionary"></xref>.

        Remote runspace gets its application private data from the server (set when creating a remote runspace pool) 
        Calling this method on a remote runspace will block until the data is received from the server.  
        The server will send application private data before reaching <xref href="System.Management.Automation.Runspaces.RunspacePoolState.Opened"></xref> state.

        Runspaces that are part of a <xref href="System.Management.Automation.Runspaces.RunspacePool"></xref> inherit application private data from the pool.
GetCapabilities()

Returns Runspace capabilities.

GetRunspace(RunspaceConnectionInfo, Guid, Nullable<Guid>, PSHost, TypeTable)
GetRunspaces(RunspaceConnectionInfo)

Queries the server for disconnected runspaces and creates an array of runspace objects associated with each disconnected runspace on the server. Each runspace object in the returned array is in the Disconnected state and can be connected to the server by calling the Connect() method on the runspace.

GetRunspaces(RunspaceConnectionInfo, PSHost)

Queries the server for disconnected runspaces and creates an array of runspace objects associated with each disconnected runspace on the server. Each runspace object in the returned array is in the Disconnected state and can be connected to the server by calling the Connect() method on the runspace.

GetRunspaces(RunspaceConnectionInfo, PSHost, TypeTable)

Queries the server for disconnected runspaces and creates an array of runspace objects associated with each disconnected runspace on the server. Each runspace object in the returned array is in the Disconnected state and can be connected to the server by calling the Connect() method on the runspace.

OnAvailabilityChanged(RunspaceAvailabilityEventArgs)

Raises the AvailabilityChanged event

Open()

Opens the runspace synchronously. Runspace must be opened before it can be used.

OpenAsync()

Open the runspace Asynchronously.

ResetRunspaceState()

Resets the variable table for the runspace to the default state.

SetBaseTransaction(CommittableTransaction)

Sets the base transaction for the runspace; any transactions created on this runspace will be nested to this instance

SetBaseTransaction(CommittableTransaction, RollbackSeverity)

Sets the base transaction for the runspace; any transactions created on this runspace will be nested to this instance

UpdateRunspaceAvailability(RunspaceState, Boolean)

Used to update the runspace availability event when the state of the runspace changes

Events

AvailabilityChanged

Event raised when the availability of the Runspace changes.

StateChanged

Event raised when RunspaceState changes.