Condividi tramite


Runspace Class

Definition

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

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

Properties

ApartmentState

ApartmentState of the thread used to execute commands within this Runspace.

CanUseDefaultRunspace

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

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

DisconnectedOn property applies to remote runspaces that have been disconnected.

Events

Gets the event manager.

ExpiresOn

ExpiresOn property applies to remote runspaces that have been disconnected.

Id

Gets the Runspace Id.

InitialSessionState

InitialSessionState information for this runspace.

InstanceId

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

JobManager

Manager for JobSourceAdapters registered in this runspace.

Name

Gets and sets a friendly name for the Runspace.

OriginalConnectionInfo

ConnectionInfo originally supplied by the user.

RunspaceAvailability

Gets the current availability of the Runspace.

RunspaceConfiguration

RunspaceConfiguration information for this runspace.

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

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()

Creates a nested pipeline.

CreateNestedPipeline(String, Boolean)

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 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()

Returns Runspace capabilities.

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)

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.

Applies to