Compartir a través de


PowerShell.AddArgument(Object) 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(System::Object ^ value);
public System.Management.Automation.PowerShell AddArgument (object value);
member this.AddArgument : obj -> System.Management.Automation.PowerShell
Public Function AddArgument (value As Object) As PowerShell

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.

Applies to