PowerShell.AddCommand
Method
Definition
Overloads
| AddCommand(CommandInfo) |
CommandInfo object for the command to add. |
| AddCommand(String) |
Add a cmdlet to construct a command pipeline. For example, to construct a command string "get-process | sort-object",
|
| AddCommand(String, Boolean) |
Add a cmdlet to construct a command pipeline. For example, to construct a command string "get-process | sort-object",
|
AddCommand(CommandInfo)
CommandInfo object for the command to add.
public System.Management.Automation.PowerShell AddCommand (System.Management.Automation.CommandInfo commandInfo);
- commandInfo
- CommandInfo
The CommandInfo object for the command to add
A PSCommand instance with the command added.
command is null.
Powershell instance cannot be changed in its current state.
Object is disposed.
Remarks
This method is not thread-safe.
AddCommand(String)
Add a cmdlet to construct a command pipeline. For example, to construct a command string "get-process | sort-object",
PowerShell shell = PowerShell.Create("get-process").AddCommand("sort-object");
public System.Management.Automation.PowerShell AddCommand (string cmdlet);
- cmdlet
- String
A string representing cmdlet.
A PowerShell instance with cmdlet added.
cmdlet is null.
Powershell instance cannot be changed in its current state.
Object is disposed.
Remarks
This method is not thread safe.
AddCommand(String, Boolean)
Add a cmdlet to construct a command pipeline. For example, to construct a command string "get-process | sort-object",
PowerShell shell = PowerShell.Create("get-process").AddCommand("sort-object");
public System.Management.Automation.PowerShell AddCommand (string cmdlet, bool useLocalScope);
- cmdlet
- String
A string representing cmdlet.
- useLocalScope
- Boolean
if true local scope is used to run the script command.
A PowerShell instance with cmdlet added.
cmdlet is null.
Powershell instance cannot be changed in its current state.
Object is disposed.
Remarks
This method is not thread safe.