The one line that makes a reboot part of an automation run rather than the end of it: the host restarts, ServerEngine waits for it to come back and the runbook continues at the next script. Everything else in this library that reports a pending reboot exists to be chained in front of it.
powershell
# ServerEngine can handle system reboot cycles
# and seemlesy continue the next scripts when using Runbooks.
# ServerEngine initiates a waiting sequence and after
# successfull reconnection the cycle ends
#-------------------------------------------------
# Use this specific line for managed reboot cycles
Invoke-Command { Start-Sleep 3;Write-Host " ""State : Reboot"" ";Restart-Computer -Force }; Exit-PSSessionRun 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-17Pass Parameters into a PowerShell Script from an API
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.