← script library

Pass Parameters into a PowerShell Script from an API

ServerEngine PlatformAugust 17, 2026

Shows how an API call substitutes values into a script before it runs: any x-prefixed token is a dynamic parameter, and you can define as many as the job needs. This is why the Active Directory onboarding script is full of xName and xDepartment placeholders instead of hard-coded values.

powershell
# You can replace data/text in a script requested by the API
<#-----------------------------------------------------
# Ex. Variable = "Value" (called with API after the status variable)
# any variable after is indicated as dynamic parameters and
# you can use as many as you needed
#
# xTest1 = "someText"
# xTest2 = "verysomesome"
#>

# Exmaple 1 (Log Text)
Write-Host "<WRITE-LOG = ""*xTest1*"">"

# Exmaple 2 (Log Variable)
$log = "xTest2"
Write-Host "<WRITE-LOG = ""*$log*"">"

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.