Condividi tramite


ICommandRuntime Interface

Definition

This interface defines the set of functionality that must be implemented to directly execute an instance of a Cmdlet.

public interface class ICommandRuntime
public interface ICommandRuntime
[System.Runtime.CompilerServices.NullableContext(2)]
public interface ICommandRuntime
type ICommandRuntime = interface
[<System.Runtime.CompilerServices.NullableContext(2)>]
type ICommandRuntime = interface
Public Interface ICommandRuntime
Derived
Attributes

Remarks

When a cmdlet is instantiated and run directly, all calls to the stream APIs will be proxied through to an instance of this class. For example, when a cmdlet calls WriteObject, the WriteObject implementation on the instance of the class implementing this interface will be called. PowerShell implementation provides a default implementation of this class for use with standalone cmdlets as well as the implementation provided for running in the engine itself.

If you do want to run Cmdlet instances standalone and capture their output with more fidelity than is provided for with the default implementation, then you should create your own implementation of this class and pass it to cmdlets before calling the Cmdlet Invoke() or Execute() methods.

Properties

CurrentPSTransaction

Gets an object that surfaces the current PowerShell transaction. When this object is disposed, PowerShell resets the active transaction.

Host

Returns an instance of the PSHost implementation for this environment.

Methods

ShouldContinue(String, String, Boolean, Boolean)

Called to confirm an operation or grouping of operations with the user. This differs from ShouldProcess in that it is not affected by preference settings or command-line parameters, it always does the query. This variant offers Yes, No, YesToAll and NoToAll.

ShouldContinue(String, String)

Called by a cmdlet to confirm an operation or grouping of operations with the user. This differs from ShouldProcess in that it is not affected by preference settings or command-line parameters, it always does the query. This variant only offers Yes/No, not YesToAll/NoToAll.

ShouldProcess(String, String, String, ShouldProcessReason)

Called by a cmdlet to confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.

This variant allows the caller to specify the complete text describing the operation, rather than just the name and action.

ShouldProcess(String, String, String)

Called by a cmdlet to confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.

This variant allows the caller to specify the complete text describing the operation, rather than just the name and action.

ShouldProcess(String, String)

Called by a cmdlet to confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.

This variant allows the caller to specify text for both the target resource and the action.

ShouldProcess(String)

Called by the cmdlet to confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.

ThrowTerminatingError(ErrorRecord)

This interface will be called to route fatal errors from a cmdlet.

TransactionAvailable()

Returns true if a transaction is available and active.

WriteCommandDetail(String)

Write text into pipeline execution log.

WriteDebug(String)

Display debug information.

WriteError(ErrorRecord)

Internal variant: Writes the specified error to the error pipe.

WriteObject(Object, Boolean)

Called to write one or more objects to the output pipe. If the object is a collection and the enumerateCollection flag is true, the objects in the collection will be written individually.

WriteObject(Object)

Called to write objects to the output pipe.

WriteProgress(Int64, ProgressRecord)

Displays progress output if enabled.

WriteProgress(ProgressRecord)

Called by the cmdlet to display progress information.

WriteVerbose(String)

Called when the cmdlet want to display verbose information.

WriteWarning(String)

Called by the cmdlet to display warning information.

Applies to