Windows desktop applications
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Cmdlet Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Serves as a base class for derived cmdlets that do not depend on the Windows PowerShell runtime and that can be called directly from within another cmdlet.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)


public abstract class Cmdlet : InternalCommand

NameDescription
System_CAPS_protmethodCmdlet()

Creates a new Cmdlet object.

NameDescription
System_CAPS_pubpropertyCommandRuntime

Gets and sets the command runtime object that controls what happens when the cmdlet writes an object to the pipeline.

System_CAPS_pubpropertySystem_CAPS_staticCommonParameters

Lists the common parameters that are added by the PowerShell engine to any cmdlet that derives from PSCmdlet. Introduced in Windows PowerShell 4.0.

System_CAPS_pubpropertyCurrentPSTransaction

Gets the latest transaction started by running the Start-Transaction cmdlet. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertySystem_CAPS_staticOptionalCommonParameters

Lists the common parameters that are added by the PowerShell engine when a cmdlet defines additional capabilities (SupportsShouldProcess, SupportsTransactions). Introduced in Windows PowerShell 4.0.

System_CAPS_pubpropertyStopping

Gets an indicator that the pipeline is stopping. The pipeline can be stopped for numerous reasons, such as when the user has entered the key combination CTRL+C, a terminating error has occurred, the hosting application requested a stop, and so on.

NameDescription
System_CAPS_protmethodBeginProcessing()

Provides a one-time, preprocessing functionality for the cmdlet.

System_CAPS_protmethodEndProcessing()

Provides a one-time, post-processing functionality for the cmdlet.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetResourceString(String, String)

Gets a resource string that corresponds to the specified resource base key and identifier.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInvoke()

Invokes a cmdlet object and returns a collection of results.

System_CAPS_pubmethodInvoke<T>()

Invokes a cmdlet object, and returns a strongly-typed enumerator.

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodProcessRecord()

Provides a record-by-record processing functionality for the cmdlet.

System_CAPS_pubmethodShouldContinue(String, String)

Requests confirmation of an operation from the user by sending a second query to the user.

System_CAPS_pubmethodShouldContinue(String, String, Boolean, Boolean, Boolean)

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.

System_CAPS_pubmethodShouldContinue(String, String, Boolean, Boolean)

Requests confirmation of an operation from the user by sending a second query to the user with yesToall and noToall options.

System_CAPS_pubmethodShouldProcess(String)

Requests confirmation from the user before an operation is performed. This method sends the name of the resource to be changed so that the user can decide if the operation should continue.

System_CAPS_pubmethodShouldProcess(String, String)

Requests confirmation from the user before an operation is performed. This method sends the operation that is to be performed and the name of the resource to be changed so that the user can decide if the operation should continue.

System_CAPS_pubmethodShouldProcess(String, String, String)

Requests confirmation from the user before an operation is performed. This method sends a description of the operation to be performed, a warning message that can include query, and a caption for the warning message.

System_CAPS_pubmethodShouldProcess(String, String, String, ShouldProcessReason)

Requests confirmation from the user before an operation is performed. This method sends a detailed description of the resource to be changed and the operation to be performed to the user for confirmation before the operation is performed.

System_CAPS_protmethodStopProcessing()

Stops processing records when the user stops the cmdlet asynchronously.

System_CAPS_pubmethodThrowTerminatingError(ErrorRecord)

Reports a terminating error when the cmdlet cannot continue, or when you do not want the cmdlet to continue to process records.

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodTransactionAvailable()

Determines whether the Start-Transaction cmdlet has been called and that there is a Windows PowerShell transaction available that the cmdlet can participate in. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodWriteCommandDetail(String)

Writes information to the execution log of the pipeline.

System_CAPS_pubmethodWriteDebug(String)

Writes a debug message to the host.

System_CAPS_pubmethodWriteError(ErrorRecord)

Reports a nonterminating error to the error pipeline when the cmdlet cannot process a record but can continue to process other records.

System_CAPS_pubmethodWriteInformation(InformationRecord)

Route information to the user or host.

System_CAPS_pubmethodWriteInformation(Object, String[])

Route information to the user or host.

System_CAPS_pubmethodWriteObject(Object)

Writes a single object to the output pipeline.

System_CAPS_pubmethodWriteObject(Object, Boolean)

Writes an object to the output pipeline that can be enumerated by Windows PowerShell.

System_CAPS_pubmethodWriteProgress(ProgressRecord)

Writes a progress record to the host.

System_CAPS_pubmethodWriteVerbose(String)

Writes a general user-level message to the pipeline. These messages can help describe what the cmdlet is doing.

System_CAPS_pubmethodWriteWarning(String)

Writes a warning message that can be displayed.

Deriving from this class means that your cmdlet is using the minimum set of dependencies on the Windows PowerShell runtime. This has two benefits. First, your cmdlet objects are smaller and you are less likely to be affected by changes to the Windows PowerShell runtime. Second, if you have to, you can create an instance of the cmdlet object and invoke it directly instead of invoking it through the Windows PowerShell runtime.

Classes that derive from Cmdlet must also declare the cmdlet attribute to identify themselves as a Windows PowerShell cmdlet class. For more information about the guidelines for writing cmdlets, see Cmdlet Development Guidelines.

This class provides the following virtual methods that are called by the runtime. Cmdlets must override at least one of these methods to process records. In this SDK, these methods are often referred to as the input processing methods.

Cmdlets can also be derived from the PSCmdlet class. Deriving from this class provides access to the Windows PowerShell runtime. For more information about the differences between cmdlets based on the two base cmdlet classes, see Cmdlet Overview.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft