PSCommand Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines a PowerShell command / script object which can be used with PowerShell object.
public ref class PSCommand sealed
public sealed class PSCommand
type PSCommand = class
Public NotInheritable Class PSCommand
- Inheritance
-
PSCommand
Constructors
PSCommand() |
Creates an empty PSCommand; a command or script must be added to this PSCommand before it can be executed. |
Properties
Commands |
Gets the collection of commands from this PSCommand instance. |
Methods
AddArgument(Object) |
Adds an argument to the last added command. For example, to construct a command string "get-process | select-object name"
This will add the value "name" to the positional parameter list of "select-object" cmdlet. When the command is invoked, this value will get bound to positional parameter 0 of the "select-object" cmdlet which is "Property". |
AddCommand(Command) |
Add a Command element to the current command pipeline. |
AddCommand(String, Boolean) |
Add a cmdlet to construct a command pipeline. For example, to construct a command string "get-process | sort-object",
|
AddCommand(String) |
Add a command to construct a command pipeline. For example, to construct a command string "get-process | sort-object",
|
AddParameter(String, Object) |
Add a parameter to the last added command. For example, to construct a command string "get-process | select-object -property name"
|
AddParameter(String) |
Adds a switch parameter to the last added command. For example, to construct a command string "get-process | sort-object -descending"
|
AddScript(String, Boolean) |
Add a piece of script to construct a command pipeline. For example, to construct a command string "get-process | foreach { $_.Name }"
|
AddScript(String) |
Add a piece of script to construct a command pipeline. For example, to construct a command string "get-process | foreach { $_.Name }"
|
AddStatement() |
Adds an additional statement for execution For example,
|
Clear() |
Clears the command(s). |
Clone() |
Creates a shallow copy of the current PSCommand. |