Runspace Runspace Runspace Class

Definition

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

public abstract class Runspace : IDisposable
type Runspace = class
    interface IDisposable
Public MustInherit Class Runspace
Implements IDisposable
Inheritance
RunspaceRunspaceRunspace
Implements

Properties

ApartmentState ApartmentState ApartmentState

ApartmentState of the thread used to execute commands within this Runspace

CanUseDefaultRunspace CanUseDefaultRunspace CanUseDefaultRunspace

Returns true if Runspace.DefaultRunspace can be used to create an instance of the PowerShell class with 'UseCurrentRunspace = true'.

ConnectionInfo ConnectionInfo ConnectionInfo

Connection information for remote Runspaces, null for local Runspaces

Debugger Debugger Debugger

Gets the debugger

DefaultRunspace DefaultRunspace DefaultRunspace

Gets and sets the default Runspace used to evaluate scripts

DisconnectedOn DisconnectedOn DisconnectedOn

DisconnectedOn property applies to remote runspaces that have been disconnected.

Events Events Events

Gets the event manager

ExpiresOn ExpiresOn ExpiresOn

ExpiresOn property applies to remote runspaces that have been disconnected.

Id Id Id

Gets the Runspace Id.

InitialSessionState InitialSessionState InitialSessionState

InitialSessionState information for this runspace.

InstanceId InstanceId InstanceId

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

JobManager JobManager JobManager

Manager for JobSourceAdapters registered in this runspace.

Name Name Name

Gets and sets a friendly name for the Runspace.

OriginalConnectionInfo OriginalConnectionInfo OriginalConnectionInfo

ConnectionInfo originally supplied by the user

RunspaceAvailability RunspaceAvailability RunspaceAvailability

Gets the current availability of the Runspace

RunspaceConfiguration RunspaceConfiguration RunspaceConfiguration

RunspaceConfiguration information for this runspace.

RunspaceIsRemote RunspaceIsRemote RunspaceIsRemote

Return whether the Runspace is Remote We can determine this by whether the runspace is an implementation of LocalRunspace or infer it from whether the ConnectionInfo property is null If it happens to be an instance of a LocalRunspace, but has a non-null ConnectionInfo we declare it to be remote

RunspaceStateInfo RunspaceStateInfo RunspaceStateInfo

Retrieve information about current state of the runspace

SessionStateProxy SessionStateProxy SessionStateProxy

Gets session state proxy

ThreadOptions ThreadOptions ThreadOptions

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

Version Version Version

Return version of this runspace

Methods

ClearBaseTransaction() ClearBaseTransaction() ClearBaseTransaction()

Clears the transaction set by SetBaseTransaction()

Close() Close() Close()

Close the runspace synchronously.

CloseAsync() CloseAsync() CloseAsync()

Close the runspace Asynchronously.

Connect() Connect() Connect()

Connects the runspace to its remote counterpart synchronously.

ConnectAsync() ConnectAsync() ConnectAsync()

Connects a runspace to its remote counterpart asynchronously.

CreateDisconnectedPipeline() CreateDisconnectedPipeline() CreateDisconnectedPipeline()

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

CreateDisconnectedPowerShell() CreateDisconnectedPowerShell() CreateDisconnectedPowerShell()

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

CreateNestedPipeline(String, Boolean) CreateNestedPipeline(String, Boolean) CreateNestedPipeline(String, Boolean)

Creates a nested pipeline.

CreateNestedPipeline() CreateNestedPipeline() CreateNestedPipeline()

Creates a nested pipeline.

CreatePipeline() CreatePipeline() CreatePipeline()

Create an empty pipeline

CreatePipeline(String) CreatePipeline(String) CreatePipeline(String)

Creates a pipeline for specified command string

CreatePipeline(String, Boolean) CreatePipeline(String, Boolean) CreatePipeline(String, Boolean)

Create a pipeline from a command string.

Disconnect() Disconnect() Disconnect()

Disconnects the runspace synchronously.

DisconnectAsync() DisconnectAsync() DisconnectAsync()

Disconnects the runspace asynchronously.

Dispose() Dispose() Dispose()

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

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Protected dispose which can be overridden by derived classes.

GetApplicationPrivateData() GetApplicationPrivateData() 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 PSPrimitiveDictionary.

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 Opened state.

Runspaces that are part of a RunspacePool inherit application private data from the pool.

GetCapabilities() GetCapabilities() GetCapabilities()

Returns Runspace capabilities.

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

Returns a single disconnected Runspace object targeted to the remote computer and remote session as specified by the connection, session Id, and command Id parameters.

GetRunspaces(RunspaceConnectionInfo) GetRunspaces(RunspaceConnectionInfo) 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) GetRunspaces(RunspaceConnectionInfo, PSHost) 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) GetRunspaces(RunspaceConnectionInfo, PSHost, TypeTable) 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) OnAvailabilityChanged(RunspaceAvailabilityEventArgs) OnAvailabilityChanged(RunspaceAvailabilityEventArgs)

Raises the AvailabilityChanged event

Open() Open() Open()

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

OpenAsync() OpenAsync() OpenAsync()

Open the runspace Asynchronously.

ResetRunspaceState() ResetRunspaceState() ResetRunspaceState()

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

SetBaseTransaction(CommittableTransaction) SetBaseTransaction(CommittableTransaction) SetBaseTransaction(CommittableTransaction)

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

SetBaseTransaction(CommittableTransaction, RollbackSeverity) SetBaseTransaction(CommittableTransaction, RollbackSeverity) 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) UpdateRunspaceAvailability(RunspaceState, Boolean) UpdateRunspaceAvailability(RunspaceState, Boolean)

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

Events

AvailabilityChanged AvailabilityChanged AvailabilityChanged

Event raised when the availability of the Runspace changes.

StateChanged StateChanged StateChanged

Event raised when RunspaceState changes.

Applies to