Creates a new background script for the tenant.
Uploads a PowerShell script that Esper will execute on devices, depending on the always_run and frequency_in_mins fields.
About Background Scripts Background Scripts let a tenant run custom automation directly on managed devices (currently Windows, via the powershell interpreter) outside of Esper's built-in commands — for example, custom health checks, remediation logic, or integration with third-party tooling.
Key Fields / Query Parameters
script— The script content to execute on devicesinterpreter— Interpreter used to run the script — currently only powershell is supportedalways_run— Whether the script runs continuously; when true, frequency_in_mins must be nullfrequency_in_mins— Interval in minutes between executions; required when always_run is falsetimeout_in_mins— Maximum runtime before the script is terminated; must be > 0, defaults to 60
Common Use Cases
- Running a custom health check or diagnostic script on a recurring schedule across a device fleet
- Automating a remediation step that built-in commands don't cover
- Integrating with a third-party monitoring or compliance tool via a script
Best Practices
- Set an appropriate timeout_in_mins so a misbehaving script doesn't run indefinitely on a device
- Test a new script on a small blueprint/device scope before deploying broadly
- Use always_run only for scripts genuinely meant to run continuously — otherwise set a frequency_in_mins to control execution cadence
Workflow
- Write and test the PowerShell script content
- POST it to this endpoint with the desired always_run/frequency_in_mins/timeout_in_mins settings
- Reference the created background script from a Blueprint to deploy it to devices
Interpreter used to run the script. Currently only 'powershell' is supported.
Whether the script runs continuously. When true, frequency_in_mins must be null.
Interval in minutes between script executions. Required when always_run is false, must be null when always_run is true.
Maximum runtime in minutes before the script is terminated. Must be > 0. Defaults to 60 if omitted.
- Mock serverhttps://develop-api.esper.io/_mock/openapi/v2/background-scripts/
- https://develop-api.esper.cloud/apihttps://develop-api.esper.cloud/api/v2/background-scripts/
curl -i -X POST \
https://develop-api.esper.io/_mock/openapi/v2/background-scripts/ \
-H 'Content-Type: application/json' \
-d '{
"name": "string",
"script": "string",
"interpreter": "powershell",
"always_run": true,
"frequency_in_mins": 0,
"timeout_in_mins": 60,
"description": "string"
}'{ "content": { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "interpreter": "string", "always_run": true, "frequency_in_mins": 0, "timeout_in_mins": 0, "description": "string", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "created_by": 0, "updated_by": 0 }, "message": "string", "code": 201 }