PowerShell Component
Properties Methods Events Configuration Settings Errors
The PowerShell component can be used as a simple means of hosting the PowerShell scripting engine inside an application.
Syntax
TibsPowerShell
Remarks
PowerShell can be used to execute PowerShell commands on a PowerShell runspace, add variables to the runspace and process the results of the pipeline execution.
Prior to calling Eval or EvalFile any custom functions must be added by calling AddFunction. At the time of execution when the function is called the Function event will fire. Within this event the Parameters property may be queried to obtain information about the function parameters. Calculate the and provide the return value within Function.
By default no profiles are loaded, however LoadProfiles may be set to True to load profiles. The AddVariable method may also be used to add a variable to the running context.
To execute the PowerShell script call Eval or EvalFile. The output is returned by these methods. If any errors occur during processing the Error event will fire.
A separate library is required to execute PowerShell scripts. The "powershellobjects1m.ia32.dll" and the "powershellobjects1m.x64.dll" files are present in the lib and lib64 folders respectively. Depending on the target platform of your project (32 bit or 64 bit) one of the above dlls must be available at runtime.
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.
Property List
The following is the full list of the properties of the component with short descriptions. Click on the links for further details.
LoadProfiles | Whether to load profiles. |
ParametersPropertyCount | The number of records in the ParametersProperty arrays. |
ParametersPropertyType | The type of the parameter. |
ParametersPropertyValue | The value of the parameter. |
Method List
The following is the full list of the methods of the component with short descriptions. Click on the links for further details.
AddFunction | Adds a custom function. |
AddVariable | Sets the value of a variable in the PowerShell Runspace. |
Close | Closes the current PowerShell runspace. |
Config | Sets or retrieves a configuration setting . |
Eval | Execute a command on the PowerShell runspace. |
EvalFile | Execute a script file on the PowerShell runspace. |
Interrupt | Stops the execution of the current command. |
Event List
The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.
Error | Information about errors during data delivery. |
Function | Fired when a custom function is called. |
Configuration Settings
The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.
ProfileId | The profile Id to look for when loading profiles. |
CodePage | The system code page used for Unicode to Multibyte translations. |