Reads a list of service names from the runbook variable a check step filled in, and restarts each one that is not running, verifying the state afterwards. The self-healing half of a two-step runbook: one script decides what is broken, this one fixes it.
powershell
# Self-Healing Service Monitor
# Restarts important services automatically if stopped.
#-----------------------------------------------------------------
$ServiceDownList = $store
Write-Host "<WRITE-LOG = ""*ServiceDownList: $ServiceDownList*"">"
foreach ($ServiceName in $ServiceDownList) {
if ($Service.Status -notlike 'Running') {
$Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
Restart-Service -Name $ServiceName -Force
Start-Sleep 2
$Service.Refresh()
if ($Service.Status -eq 'Running') {
Write-Host "<WRITE-LOG = ""*Service: $ServiceName restarted successfully.*"">"
} else {
Write-Host "<WRITE-LOG = ""*Service: $ServiceName failed to start.*"">"
}
}
}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 Self-Healing & Repair
Clear the Windows Update Cache with PowerShell
2026-08-17Automate Disk Cleanup with PowerShell
2026-08-17Remove Windows Bloatware Apps with PowerShell
2026-08-17Flush the DNS Cache with PowerShell
2026-08-17Clear a Stuck Print Queue with PowerShell
2026-08-17Delete Old Temp Files with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.