CommandInvocationIntrinsics.InvokeScript CommandInvocationIntrinsics.InvokeScript CommandInvocationIntrinsics.InvokeScript Method

Definition

Overloads

InvokeScript(String) InvokeScript(String) InvokeScript(String)

Executes a piece of text as a script synchronously.

InvokeScript(String, Object[]) InvokeScript(String, Object[]) InvokeScript(String, Object[])

Executes a piece of text as a script synchronously.

InvokeScript(SessionState, ScriptBlock, Object[]) InvokeScript(SessionState, ScriptBlock, Object[])
InvokeScript(Boolean, ScriptBlock, IList, Object[]) InvokeScript(Boolean, ScriptBlock, IList, Object[])

Invoke a scriptblock in the current runspace, controlling if it gets a new scope.

InvokeScript(String, Boolean, PipelineResultTypes, IList, Object[]) InvokeScript(String, Boolean, PipelineResultTypes, IList, Object[]) InvokeScript(String, Boolean, PipelineResultTypes, IList, Object[])

Executes a piece of text as a script synchronously using the options provided.

InvokeScript(String) InvokeScript(String) InvokeScript(String)

Executes a piece of text as a script synchronously.

public System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeScript (string script);
member this.InvokeScript : string -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Public Function InvokeScript (script As String) As Collection(Of PSObject)
Parameters
script
String String String

The script text to evaluate

Returns

A collection of MshCobjects generated by the script.

Exceptions

Thrown if there was a parsing error in the script.

Represents a script-level exception

Thrown if there was a parsing error in the script.

InvokeScript(String, Object[]) InvokeScript(String, Object[]) InvokeScript(String, Object[])

Executes a piece of text as a script synchronously.

public System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeScript (string script, params object[] args);
member this.InvokeScript : string * obj[] -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Public Function InvokeScript (script As String, ParamArray args As Object()) As Collection(Of PSObject)
Parameters
script
String String String

The script text to evaluate

args
Object[]

The arguments to the script

Returns

A collection of MshCobjects generated by the script.

Exceptions

Thrown if there was a parsing error in the script.

Represents a script-level exception

Thrown if there was a parsing error in the script.

InvokeScript(SessionState, ScriptBlock, Object[]) InvokeScript(SessionState, ScriptBlock, Object[])

public System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeScript (System.Management.Automation.SessionState sessionState, System.Management.Automation.ScriptBlock scriptBlock, params object[] args);
member this.InvokeScript : System.Management.Automation.SessionState * System.Management.Automation.ScriptBlock * obj[] -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Parameters
args
Object[]
Returns

InvokeScript(Boolean, ScriptBlock, IList, Object[]) InvokeScript(Boolean, ScriptBlock, IList, Object[])

Invoke a scriptblock in the current runspace, controlling if it gets a new scope.

public System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeScript (bool useLocalScope, System.Management.Automation.ScriptBlock scriptBlock, System.Collections.IList input, params object[] args);
member this.InvokeScript : bool * System.Management.Automation.ScriptBlock * System.Collections.IList * obj[] -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Parameters
useLocalScope
Boolean Boolean Boolean

If true, a new scope will be created

scriptBlock
ScriptBlock ScriptBlock ScriptBlock

The scriptblock to execute

input
IList IList IList

Optionall input to the command

args
Object[]

Arguments to pass to the scriptblock

Returns

The result of the evaluation

InvokeScript(String, Boolean, PipelineResultTypes, IList, Object[]) InvokeScript(String, Boolean, PipelineResultTypes, IList, Object[]) InvokeScript(String, Boolean, PipelineResultTypes, IList, Object[])

Executes a piece of text as a script synchronously using the options provided.

public System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject> InvokeScript (string script, bool useNewScope, System.Management.Automation.Runspaces.PipelineResultTypes writeToPipeline, System.Collections.IList input, params object[] args);
member this.InvokeScript : string * bool * System.Management.Automation.Runspaces.PipelineResultTypes * System.Collections.IList * obj[] -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>
Public Function InvokeScript (script As String, useNewScope As Boolean, writeToPipeline As PipelineResultTypes, input As IList, ParamArray args As Object()) As Collection(Of PSObject)
Parameters
script
String String String

The script to evaluate.

useNewScope
Boolean Boolean Boolean

If true, evaluate the script in its own scope. If false, the script will be evaluated in the current scope i.e. it will be "dotted"

writeToPipeline
PipelineResultTypes PipelineResultTypes PipelineResultTypes

If set to Output, all output will be streamed to the output pipe of the calling cmdlet. If set to None, the result will be returned to the caller as a collection of PSObjects. No other flags are supported at this time and will result in an exception if used.

input
IList IList IList

The list of objects to use as input to the script.

args
Object[]

The array of arguments to the command.

Returns

A collection of MshCobjects generated by the script. This will be empty if output was redirected.

Exceptions

Thrown if there was a parsing error in the script.

Represents a script-level exception

Thrown if there was a parsing error in the script.

Applies to