Service Checker 5 Million
- ToddimusPrime
- May 11, 2021
- 1 min read
Monthly server patching is one of those things that happens every month for us sysadmin types. Have you ever noticed that sometimes a few of the automatic services just don't start automatically after an update, then the next morning your users are all yelling about a website, database, or quake server that isn't working? Run this script to get a handy list of any automatic services that aren't running.
Start by making a txt file with a list of your server hostnames, one per line, then run this thing. Any automatic services that aren't running will show up in some nice red text.
$servers = Get-Content <PATH TO YOUR TXT FILE GOES HERE>
foreach ($server in $servers)
{
$output = Get-WmiObject win32_service -computername $server -Filter "startmode = 'auto' AND state != 'running' AND Exitcode != 0" | Select-Object name,state
if([string]::IsNullOrEmpty($output))
{
Write-Host $server "is ok `n" -ForegroundColor Green
}
else
{
Write-Host $server "`n" $output "`n`n" -ForegroundColor Red
}
}Happy Patch Tuesday, everyone!




Comments