Skip to main content
On-Prem > Scripts holds the PowerShell your workflows run on a client’s machine through the desktop agent. The client needs an installed agent showing Online.

On-prem scripts: writing a script, running it from a workflow through Globex's agent, and reading what it returned (1:28).

The Scripts page, Manage your PowerShell scripts, with Refresh and New Script buttons, a Search scripts box and one script, Docs sample – Unlock AD account, with Edit and delete actions.

Example: unlock an AD account

The script unlocks a user in a client’s Active Directory and reports their last logon.
1

Write the script

Click New Script, name it, paste the script and click Create Script.
The Create New Script dialog with the name Docs sample – Unlock AD account and the unlock script in the PowerShell Script Editor, with Cancel and Create Script buttons.
{{Username}} is a parameter Triggr fills in before the script runs; $ErrorActionPreference = 'Stop' makes any error fail the run, and the last line returns the result as one line of JSON.
2

Run it from a workflow

Add Execute PowerShell (Timeout) from On Prem and rename it Unlock Account with the pencil (it starts as Execute Powershell With Timeout). Choose the script, fill in Parameters and set Client ID (or leave it empty to use the client an earlier Client step set).
The Unlock Account step: Script Docs sample – Unlock AD account, Parameters with Username set to ctx.params.username with the json filter, Timeout (seconds) 120 and Client ID set to ctx.params.clientId.
Each key in Parameters fills the placeholder with the same name; | json keeps quotes in form or webhook values from breaking the JSON (see Build JSON).
3

Handle each outcome

Connect the Completed, Failed and Timed Out branches; Timed Out means no agent reported back in time, usually because it’s offline.
A workflow canvas: Trigger, then Unlock Account with three branches labelled Completed, Failed and Timed Out, leading to Read Result then Done, Script Failed, and Agent Offline.
4

Read the result

The script’s output arrives as text in output. On the Completed branch, add a Code step named Read Result that parses it, so later steps can use {{ ctx.steps['Read Result'].lastLogonDate }}.
The Read Result Code step with JavaScript return JSON.parse(ctx.steps['Unlock Account'].output);
5

Test it

Save, click Manual Trigger and enter a real user and the client’s ID from its page in Clients. The run waits on Unlock Account until the agent reports back; click the step to see its output.
The Trigger Workflow dialog with JSON giving a clientId of 11111111-2222-3333-4444-555555555555 and username jane.doe, and Cancel and Trigger Workflow buttons.

What the step returns

The plain Execute PowerShell step has no deadline or branches: it waits for an agent, then carries on whether the script worked or not, so check {{ ctx.steps['Step name'].completed }} in a Condition step. Check Agents Online tests an agent is up first (On Prem steps).

How scripts run

  • The agent stops a script after 10 minutes, whatever the step’s timeout, and the step fails.
  • Scripts run in PowerShell 7 if it’s installed, otherwise Windows PowerShell 5.1, under the agent service’s account (Local System unless you changed it).
  • Any online agent for the client can run the script, so install the modules you need on each.
  • A placeholder becomes the value’s text exactly. Keep it in single quotes and check form input first: a ' in the value ends the string early.

Executions

On-Prem > Executions lists every run with its script, client and status; a run is Pending until an agent picks it up. Runs that timed out show under All Statuses. Click View for its parameters, output and error.
The PowerShell Executions page, View and manage PowerShell script executions, with a Search executions box, an All Statuses filter and Script, Client, Status, Created and Actions columns.
Parameters show in full on the execution’s page and in the workflow run, so don’t pass passwords to scripts: generate them on the machine.

FAQ

No. Make a small workflow with an Execute PowerShell step and run it with Manual Trigger.
No. Write {{Name}} wherever a value goes. A placeholder with no matching key in Parameters stays as it is.
Numbers in Parameters are written with six decimal places. Pass them as text, such as "Days": "30".
output includes Write-Host lines and warnings. Make the JSON line the only output: remove Write-Host and pipe other output to Out-Null.
Saving a script changes it for every workflow that uses it from the next run; there’s no version history, and deleting one doesn’t check which workflows use it.

Troubleshooting

No agent for that client reported back in time. Check the client’s agent is Online (Install the agent).
The script hit an error or ran past 10 minutes. output holds PowerShell’s error message.
The run has no client. Set Client ID, or start the workflow with a Client step such as Set Client By ID.
A filled-in value has quotes in it. Add | json to the template: { "Username": {{ ctx.params.username | json }} }.
The agent’s machine lacks the ActiveDirectory module. Install the RSAT Active Directory tools there, or install the agent on a domain controller.