Skip to content

Powershell Scripts

The Powershell Scripts section explains:

  • In which directory to store the Powershell Scripts
  • What JSON Object eLegere supplies to the Powershell Script and its structure.
  • What is the structure of the JSON Object with the Powershell's results.
  • How to specify additional parameters and values.
  • Differences in Powershell scripts behavior according to the usage context.

Where to Store the Powershell scripts?

eLegere stores all the Powershell scripts in a folder that the installation's administrator has configured.

Contact your eLegere administrator to store your Powershell script in the dedicated folder on the machine.

JSON Object that eLegere Provides to the Powershell

Learn the structure of the JSON Object with the row's information that eLegere provides to the Powershell script.

You Powershell script must have the @ActionContext parameter to receive a JSON Object from eLegere.

@ActionContext receives a String the JSON Data as value. The JSON Object in the string has the following structure:

  "Items": {
    "956cdabb-b752-4dea-9dc7-317bc45e202e": {
      "NewItem": {},
      "OldItem": {} | null
    "e6eeb3ac-91c6-43dc-a1f2-58705ecbe06e": {
      "NewItem": {},
      "OldItem": {} | null
  "UserId": "",
  "TimezoneMsOffset": 7200000.0

Follows an explanation of the JSON object's keys:

  • Items key lists all the rows' objects to be recorded or modified on the database.
  • GUID identifying each Storage. This object contains in turn two other objects.
    • NewItem key is the JSON object containing the row with the latest changes.
    • OldItem key is the JSON object containing the row's information before the changes.
  • UserId key is the logon's username.
  • TimezoneMsOffset key stands for the time difference between the UTC and the local client executing the action. The value is expressed in milliseconds.

JSON Object with Response's Data

Follows an explanation of the object containing the message's info and operation's result that you can encode in your Powershell script.

Your Powershell script can optionally return information to the user about the action. eLegere displays in the client a certain message and result according to the keys' values (if added to the Powershell Script).

  "Message": "",
  "ReturnCode": ""
  • Message: A String containing the message to display in the client to the user.
  • ReturnCode: The key value specifies how eLegere must behave after the Powershell execution and what result reports. If not specified and left empty, the value passed is 000200 (corresponding to a successful result of the action). See Return Codes for the list of behaviors.

Return Codes

Each code specifies a different result to communicate to the user.

Code Name Behavior
000500 Failed eLegere blocks the whole database transaction and restores the previous table's status. Displays an error message.
000200 Success eLegere displays a "Success" (This is the Default value for the ReturnCode parameter.)

How to Add Additional Parameters

Learn how to add additional parameters to a Powershell in eLegere.


See How to Embed Powershell Scripts in Your Application from the Designer Guide to learn how to create a Custom Action in eLegere. Choose the Invoke Powershell from the drop-down list.

You can specify additional parameters and keys for a Powershell. Click the New in the Custom Action's Parameters settings. The action enables to add a new couple of parameters and values.

Action Type and eLegere Behavior

Learn what values the Powershell script receives through the JSON Object from eLegere according to the action:

  • Custom Action with Event Trigger: The JSON Object passed by eLegere has the Items values with the row's information.
  • Custom Action with Manual Trigger: The JSON Object passed by eLegere has the Items value with the row's information.
  • Scheduled Job: The Powershell script runs outside an application, so the Items key has no value.
Action Items Parameter
Custom Action with Event Trigger
Custom Action with Manual Trigger
Scheduled Job