ICommandRuntime Interface

Definition

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

public interface ICommandRuntime
Derived

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. The Monad implementation provides a default implementation of this class for use with standalone cmdlets as well as the implementation provided for running in the monad 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)

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.

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.

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.

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, 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, 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.
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)

Called to write objects to the output 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.

WriteProgress(ProgressRecord)

Called by the cmdlet to display progress information

WriteProgress(Int64, ProgressRecord)

Displays progress output if enabled

WriteVerbose(String)

Called when the cmdlet want to display verbose information

WriteWarning(String)

Called by the cmdlet to display warning information