Delen via


PSCommand.AddArgument(Object) Method

Definition

Adds an argument to the last added command. For example, to construct a command string "get-process | select-object name"

PSCommand command = new PSCommand("get-process")
    .AddCommand("select-object")
    .AddArgument("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".

public:
 System::Management::Automation::PSCommand ^ AddArgument(System::Object ^ value);
public System.Management.Automation.PSCommand AddArgument (object value);
member this.AddArgument : obj -> System.Management.Automation.PSCommand
Public Function AddArgument (value As Object) As PSCommand

Parameters

value
Object

Value for the parameter.

Returns

A PSCommand instance parameter value value added to the parameter list of the last command.

Exceptions

Powershell instance cannot be changed in its current state.

Remarks

This method is not thread safe.

Applies to