← script library

Restart a List of Services with PowerShell

Self-Healing & RepairAugust 17, 2026

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.

Ready when you are.

Try ServerEngine free for 7 days.