Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

PowerShell.AddStatement Method

Definition

Namespace:
System.Management.Automation
Assembly:
System.Management.Automation.dll
Package:
Microsoft.PowerShell.5.1.ReferenceAssemblies v1.0.0
Package:
System.Management.Automation v7.4.15
Package:
System.Management.Automation v7.5.6
Package:
System.Management.Automation v7.6.1

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Adds an additional statement for execution

For example,

Runspace rs = RunspaceFactory.CreateRunspace();
PowerShell ps = PowerShell.Create();

ps.Runspace = rs;
ps.AddCommand("Get-Process").AddArgument("idle");
ps.AddStatement().AddCommand("Get-Service").AddArgument("audiosrv");
ps.Invoke();
public:
 System::Management::Automation::PowerShell ^ AddStatement();
public System.Management.Automation.PowerShell AddStatement();
member this.AddStatement : unit -> System.Management.Automation.PowerShell
Public Function AddStatement () As PowerShell

Returns

A PowerShell instance with the items in parameters added to the parameter list of the last command.

Applies to