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.

Command Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Defines a command that contains a single cmdlet or script. The Command object is used by the PowerShell and Pipeline objects to define a single command.

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

System.Object
  System.Management.Automation.Runspaces.Command

public sealed class Command

NameDescription
System_CAPS_pubmethodCommand(String)

Creates a new Command object that contains the command to be run.

System_CAPS_pubmethodCommand(String, Boolean)

Creates a new Command object that contains a command and a Boolean value that indicates whether the object contains a script.

System_CAPS_pubmethodCommand(String, Boolean, Boolean)

Creates a new Command object that contains a cmdlet or script to run, plus two Boolean values that indicate whether the object contains a script and whether the local scope should be used when invoking the script.

NameDescription
System_CAPS_pubpropertyCommandOrigin

Gets or sets the command origin for this command. A command origin of 'Runspace' (the default) applies Runspace restrictions to this command. A command origin of 'Internal' does not apply runspace restrictions.

System_CAPS_pubpropertyCommandText

Gets the command name or script of the Command object.

System_CAPS_pubpropertyIsEndOfStatement

Checks if the current command marks the end of a statement (see PowerShell.AddStatement())

System_CAPS_pubpropertyIsScript

Gets a Boolean value that indicates whether the Command object contains a script.

System_CAPS_pubpropertyMergeUnclaimedPreviousCommandResults

Gets and sets PipelineResultTypes constants that specify what output streams are merged for previous unclaimed command results.

System_CAPS_pubpropertyParameters

Gets the parameters for the command.

System_CAPS_pubpropertyUseLocalScope

Gets a Boolean value that indicates whether the Command object should be run in its own local scope.

NameDescription
System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodMergeMyResults(PipelineResultTypes, PipelineResultTypes)

Merges the results that this Command writes to one stream (such as its Error stream) with the results of another stream (such as the Output stream).

System_CAPS_pubmethodToString()

Generates a string representation of the current Command object.(Overrides Object.ToString().)

The Command object can be used in two ways.

Windows PowerShell provides two classes that can define a command. The PSCommand class allows you to build a pipeline of commands (A|B|C) that contain one or more cmdlets and scripts. In contrast, the Command class allows you to specify only a single cmdlet or script in the command.

This class cannot be inherited.

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

Community Additions

Show: