← script library

Pass Data Between Runbook Steps in PowerShell

ServerEngine PlatformAugust 17, 2026

Four worked examples of the store variable that carries a value from one runbook script to the next: plain text, a variable, a number and a list joined into a string. Half of what makes runbooks more than a list of scripts, and the reason so many scripts in this library end by filling it in.

powershell
# You can save data to the variable $store
# To use data on the next script using Runbooks
#--------------------------------------------------
function Write-Log {
    param($Message)
    Write-Host "<WRITE-LOG = `"*$Message*`">"
}

# Example 1 (Save Text)
$store = "This text was saved"

# Example 2 (Save Variable)
$message = "This variable was saved"
$store = $message

# Example 3 (Save Numeric Values)
$store = 1337

# Example 4 (Save SringList or Aarray as String)
$store = "c.orlando, m.muster"

Write-Log "Save: $store"
#--------------------------------------------------
# Check LoadData next for loading usage
#--------------------------------------------------

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.