Scripting Integrator - Online Help
Scripting Integrator
Questions / Feedback?

Eval Method

Execute a command on the PowerShell runspace.

Syntax

[VB.NET]
Public Function Eval(ByVal Command As String) As String
[C#]
public string Eval(string command);

Remarks

The Command parameter contains the text of the command to execute.

If the command writes any error objects to the error stream, these will be exposed through the Error event.

Example: Executing a command and iterating over the results

powerShell1.Execute("ls c:\\");
for ( int i=0; i < powerShell1.PSObjectCount; i++ ) {
   powerShell1.PSObjectIndex = i;
   Console.WriteLine("{0}\t{1}", powerShell1.PSObject["Name"].Value, powerShell1.PSObject["Length"]);
}

Eval Notes

When calling Eval or EvalFile any custom functions must first be defined by calling AddFunction. When the function is encountered the Function event will fire. Within this event query the Parameters collection to get the function parameter values. The return value of the custom function is defined within the Function event.

Any errors such as undefined functions or other issue will cause the Error event. Errors will not cause an exception. It is important to monitor the Error event for information about any errors that occur.

The return value from Eval or EvalFile is the output from successful execution of the JavaScript.

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
Build 1.0.6240.0