Skip to content

Introduction

Easit Process Runner, or EPR for short, makes it possible to integrate Easit GO with your existing PowerShell scripts. EPR consist of a java application running in an instance of Apache Tomcat, installed as a Windows service.

Once started, EPR listens for incoming request using a REST service. When a request is received, the JSON body of the request is passed on as a argument to a script file with the same name as the value of "importHandlerIdentifier" in the body.

    {
        "importHandlerIdentifier":"testService.ps1",
        "itemToImport":[
            {
                "property":[
                    {
                        "content":"123456",
                        "name":"requestId",
                        "rawValue":null
                    },{
                        "content":"aValue",
                        "name":"aProperty",
                        "rawValue":null
                    }
                ],
                "attachment":[],
                "id":"123456:2",
                "uid":"123456"
            }
        ],
        "genericRequestProperty":[
            {
                "content":"testService.ps1",
                "name":"identifier"
            },{
                "content":"MC0CFHnd2e81XFZezdFIHPj5i+A/6dbPAhUAkUKMTyjRZtJ7SZ6c/3KL0aeZKd4=",
                "name":"initializedByXmlExport"
            }
        ]
    }

To put in to context, the command executed by the java application, with the example above would be as shows below.

    C:\Users\administrator> pwsh.exe -ExecutionPolicy Bypass -File "Path/To/Scripts/scriptName.ps1 requestJsonBody"

To further exemplify this, our script scriptName.ps1 looks like this:

    [CmdletBinding()]
    param(
        [Parameter(Mandatory,Position=0)]
        [string]$StringInput
    )
    $exportObject = $StringInput | ConvertFrom-Json
    $easitObject = $exportObject.itemToImport[0]
    Write-Host "Received exported item $($easitObject.uid)"
    # To access the properties..
    foreach ($property in $easitObject.property) {
        Write-Host "$($property.Name) = $($property.Content) (rawValue: $($property.rawValue))"
    }
    # Access a specific property
    $easitObject.property | Where-Object {$_.Name -like "requestId"}

and will produce this output:

    Received exported item 123456
    requestId = 123456
    aProperty = aValue

    content name      rawValue
    ------- ----      --------
    123456  requestId

Once the script have completed, EPR will evaluate LASTEXITCODE. If LASTEXITCODE is anything else than 0 the java application will treat it as an error or failure.