Solarwind Powershell monitor

 

$Servername = $args[0]
$ExcludeService =@("sppsv") # put the service you would like to ignore
$RemainService = Get-Service -computername $servername | ?{$_.starttype -eq "automatic" -and $_.status -ne "Running"} | select -exp name
$count = 0foreach($Service in $RemainService){
    if(!$ExcludeService.contains($service))
    {
        $count ++
    }

}

if($count){         write-host "Statistic: $count"     exit 1
}
else
{
    write-host "Statistic: 0"
    exit 0

}

留言