PSCommand.AddParameter Method
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.
Overloads
AddParameter(String) |
Adds a switch parameter to the last added command. For example, to construct a command string "get-process | sort-object -descending"
|
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"
PSCommand command = new PSCommand("get-process")
.AddCommand("sort-object")
.AddParameter("descending");
public:
System::Management::Automation::PSCommand ^ AddParameter(System::String ^ parameterName);
public System.Management.Automation.PSCommand AddParameter (string parameterName);
member this.AddParameter : string -> System.Management.Automation.PSCommand
Public Function AddParameter (parameterName As String) As PSCommand
Parameters
- parameterName
- String
Name of the parameter.
Returns
A PSCommand instance with parameterName
added
to the parameter list of the last command.
Exceptions
Name is non null and name length is zero after trimming whitespace.
Powershell instance cannot be changed in its current state.
Remarks
This method is not thread safe.
Applies to
AddParameter(String, Object)
Add a parameter to the last added command. For example, to construct a command string "get-process | select-object -property name"
PSCommand command = new PSCommand("get-process")
.AddCommand("select-object")
.AddParameter("property", "name");
public:
System::Management::Automation::PSCommand ^ AddParameter(System::String ^ parameterName, System::Object ^ value);
public System.Management.Automation.PSCommand AddParameter (string parameterName, object value);
member this.AddParameter : string * obj -> System.Management.Automation.PSCommand
Public Function AddParameter (parameterName As String, value As Object) As PSCommand
Parameters
- parameterName
- String
Name of the parameter.
- value
- Object
Value for the parameter.
Returns
A PSCommand instance with parameterName
added
to the parameter list of the last command.
Exceptions
Name is non null and name length is zero after trimming whitespace.
Powershell instance cannot be changed in its current state.
Remarks
This method is not thread safe.