Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PowerShell.AddArgument Method (Object)

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Adds an argument for a positional parameter of a command without specifying the parameter name. This method is introduced in Windows PowerShell 2.0.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

public PowerShell AddArgument(
	object value
)

Parameters

value
Type: System.Object

The value of the argument to be added to the last command of the pipeline.

Return Value

Type: System.Management.Automation.PowerShell

A PowerShell object with the argument added at the end of the pipeline.

When an argument is added to a command, it is bound to a positional parameter when the command is invoked. The first call to this method adds the argument to the first positional parameter of the command. Subsequent calls to this method add an argument to the next positional parameter in the parameter list of the command.

To add cmdlets and scripts to the pipeline, call the AddCommand and AddScript methods.

To add parameters to a command, call the AddParameter method.

To invoke the pipeline synchronously, call the Invoke method. To invoke the pipeline asynchronously, call the BeginInvoke method.

This method is not thread safe.

The following example shows how to add an argument for a positional parameter to the last command in the pipeline. In this case, the argument s* is added to the first positional parameter of the Get-Process cmdlet.

// Using the PowerShell object, create the command 
// pipeline and add the cmdlet and the argument 
// for the positional parameter.
PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-Process");
ps.AddArgument("s*");      

Return to top

Community Additions

Show: