Export (0) Print
Expand All

Command Class

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)

Dim instance As Command

public ref class Command sealed
public final class Command
public final class Command

The Command object can be used in two ways.

  • The AddCommand method of the PowerShell object can use the Command object when creating a pipeline.

  • The Invoke or InvokeAsync methods of the Pipeline object can use the Command object when invoking the pipeline.

    In this case, the Command objects are contained in a CommandCollection that is accessed through the Commands property.

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.


Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Server 2008, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional, Windows Vista, Windows Server 2003 R2, Windows XP, Windows 7, Windows 2008 R2, Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
© 2014 Microsoft