← 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.
More in ServerEngine Platform
Write to the ServerEngine Run Log from PowerShell
2026-08-17Pass Data Between Runbook Steps in PowerShell
2026-08-17Read Data from a Previous Runbook Step in PowerShell
2026-08-17Reboot a Server and Resume the Runbook
2026-08-17Configure WinRM over HTTPS with a Self-Signed Certificate
2026-08-17Configure WinRM over HTTPS with a Domain Certificate
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.