PowerShell.AddScript
Method
Definition
Overloads
| AddScript(String) |
Add a piece of script to construct a command pipeline. For example, to construct a command string "get-process | foreach { $_.Name }"
|
| AddScript(String, Boolean) |
Add a piece of script to construct a command pipeline. For example, to construct a command string "get-process | foreach { $_.Name }"
|
AddScript(String)
Add a piece of script to construct a command pipeline. For example, to construct a command string "get-process | foreach { $_.Name }"
PowerShell shell = PowerShell.Create("get-process").
AddCommand("foreach { $_.Name }", true);
public System.Management.Automation.PowerShell AddScript (string script);
- script
- String
A string representing a script.
A PowerShell instance with command added.
command is null.
Powershell instance cannot be changed in its current state.
Object is disposed.
Remarks
This method is not thread-safe.
AddScript(String, Boolean)
Add a piece of script to construct a command pipeline. For example, to construct a command string "get-process | foreach { $_.Name }"
PowerShell shell = PowerShell.Create("get-process").
AddCommand("foreach { $_.Name }", true);
public System.Management.Automation.PowerShell AddScript (string script, bool useLocalScope);
- script
- String
A string representing a script.
- useLocalScope
- Boolean
if true local scope is used to run the script command.
A PowerShell instance with command added.
command is null.
Powershell instance cannot be changed in its current state.
Object is disposed.
Remarks
This method is not thread-safe.