Here is a PowerShell script I wrote that checks if a service is running across a cluster of servers. This is a quick display of the status that outputs to the console.

A future version of this base script includes the following improvements:
Trying to start the service
Logging
Showing you how to set this script up to run as a scheduled task or job if your enterprise has WinRM.

Code:

#Service - check

Clear-Host

for($i=1;$i -lt 10;$i++)
{$computers = "<CLUSTERNAME000>" + $i
foreach($computer in $computers)
{$results = Get-Service -computername $computer | Where-Object {$_.Name -match "<SERVICENAME>"} | Select-Object Status
foreach($result in $results)
{
if($result.Status -eq "Stopped"){Write-Host "<SERVICENAME>" -foregroundcolor red -backgroundcolor yellow $result.Status on $computer}
else
{Write-Host "<SERVICENAME>" $result.Status on $computer}
}
}
}

Leave a Reply