PSCommand.AddParameter
Method
Definition
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 (string parameterName);
- parameterName
- String
Name of the parameter.
A PSCommand instance with parameterName added
to the parameter list of the last command.
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.
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 (string parameterName, object value);
- parameterName
- String
Name of the parameter.
- value
- Object
Value for the parameter.
A PSCommand instance with parameterName added
to the parameter list of the last command.
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.