CommandInvocationIntrinsics.InvokeScript Method

Definition

Overloads

InvokeScript(String)

Executes a piece of text as a script synchronously.

InvokeScript(String, Object[])

Executes a piece of text as a script synchronously.

InvokeScript(SessionState, ScriptBlock, 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[])

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

InvokeScript(String)

Executes a piece of text as a script synchronously.

public:
 System::Collections::ObjectModel::Collection<System::Management::Automation::PSObject ^> ^ InvokeScript(System::String ^ script);
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

The script text to evaluate

Returns

Collection<PSObject>

A collection of MshCobjects generated by the script.

Exceptions

Thrown if there was a parsing error in the script.

Represents a script-level exception

Applies to

InvokeScript(String, Object[])

Executes a piece of text as a script synchronously.

public:
 System::Collections::ObjectModel::Collection<System::Management::Automation::PSObject ^> ^ InvokeScript(System::String ^ script, ... cli::array <System::Object ^> ^ args);
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

The script text to evaluate

args
Object[]

The arguments to the script

Returns

Collection<PSObject>

A collection of MshCobjects generated by the script.

Exceptions

Thrown if there was a parsing error in the script.

Represents a script-level exception

Applies to

InvokeScript(SessionState, ScriptBlock, Object[])

public:
 System::Collections::ObjectModel::Collection<System::Management::Automation::PSObject ^> ^ InvokeScript(System::Management::Automation::SessionState ^ sessionState, System::Management::Automation::ScriptBlock ^ scriptBlock, ... cli::array <System::Object ^> ^ args);
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>
Public Function InvokeScript (sessionState As SessionState, scriptBlock As ScriptBlock, ParamArray args As Object()) As Collection(Of PSObject)

Parameters

sessionState
SessionState
scriptBlock
ScriptBlock
args
Object[]

Returns

Collection<PSObject>

Applies to

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, ... cli::array <System::Object ^> ^ args);
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>
Public Function InvokeScript (useLocalScope As Boolean, scriptBlock As ScriptBlock, input As IList, ParamArray args As Object()) As Collection(Of PSObject)

Parameters

useLocalScope
Boolean

If true, a new scope will be created

scriptBlock
ScriptBlock

The scriptblock to execute

input
IList

Optionall input to the command

args
Object[]

Arguments to pass to the scriptblock

Returns

Collection<PSObject>

The result of the evaluation

Applies to

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(System::String ^ script, bool useNewScope, System::Management::Automation::Runspaces::PipelineResultTypes writeToPipeline, System::Collections::IList ^ input, ... cli::array <System::Object ^> ^ args);
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

The script to evaluate.

useNewScope
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

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

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

args
Object[]

The array of arguments to the command.

Returns

Collection<PSObject>

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 any redirect other than output is attempted

Applies to