PowerShell.AddArgument Method

Definition

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


                    PowerShell shell = PowerShell.Create("get-process").
                                                AddCommand("select-object").AddParameter("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.PowerShell AddArgument (object value);
Parameters
value
Object

Value for the parameter.

Returns

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

Remarks

This method is not thread safe.