PowerShell public

Windows Service Health

Share this script safely, inspect its metadata, and copy the exact command you need.

Dashboard

Ready to run

One-liner

Copy the command, then review before execution.
curl -fsSL https://runny.sh/r/QN7GJPTTRCN1 | pwsh

Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.494

At a glance

Script metadata

Slug
QN7GJPTTRCN1
Fetches
0
Size
1719 B · 70 lines
Expires
never
Last fetch
Created
2026-09-07 00:36:00.654
Description
Automatic services that are not running

Readable before runnable

Preview

# Windows service health
# Read-only: Get-Service, lists Automatic services that are Stopped.
# Exit 0 if current, 1 if a required service is stopped, 2 on error.
# Hosted on Runny.sh. Review the script page before you run it.

$ErrorActionPreference = 'Continue'
$status = 0

function Write-Line {
    param([string]$Text)
    Write-Output $Text
}

function Set-Warn {
    if ($script:status -lt 1) { $script:status = 1 }
}

function Set-Crit { $script:status = 2 }

Write-Line '=== Windows Automatic service health ==='
Write-Line ("Host:     {0}" -f $env:COMPUTERNAME)
Write-Line ''

try {
    $services = @(Get-Service -ErrorAction Stop)
} catch {
    Write-Line 'Get-Service failed'
    Write-Line $_.Exception.Message
    Write-Line 'Result:   ERROR'
    exit 2
}

$auto = @(
    $services | Where-Object {
        $_.StartType -eq 'Automatic' -or $_.StartType -eq 'AutomaticDelayedStart'
    }
)
$stopped = @($auto | Where-Object { $_.Status -eq 'Stopped' })

Write-Line ("Automatic services: {0}" -f $auto.Count)
Write-Line ("Stopped Automatic:  {0}" -f $stopped.Count)
Write-Line ''

if ($stopped.Count -eq 0) {
    Write-Line '  none'
    Write-Line '          OK'
} else {
    $shown = 0
    foreach ($svc in $stopped) {
        if ($shown -ge 20) {
            Write-Line ("  ... {0} more" -f ($stopped.Count - $shown))
            break
        }
        Write-Line ("  - {0}  ({1})" -f $svc.Name, $svc.DisplayName)
        $shown++
    }
    Set-Warn
}

Write-Line ''
if ($status -eq 0) {
    Write-Line 'Result:   CURRENT'
} elseif ($status -eq 1) {
    Write-Line ("Result:   ACTION NEEDED ({0} stopped Automatic service(s))" -f $stopped.Count)
} else {
    Write-Line 'Result:   ERROR'
}

exit $status

Raw endpointhttps://runny.sh/r/QN7GJPTTRCN1

See something unsafe?

Report this script

Tell us why it should come down. Anyone can also report a URL at /abuse.

Restore revision