Windows Service Misbehaviour
When you are used to working with N-Central, some obvious flaw in N-Central can easily be missed.
The default Windows Service service check in N-Central is able to detect if a service is starting, stopping or paused, but it is unable to report on it, as you can not set a threashold on it.
This issue has created an issue for a customer because his process was stuck on stopping and we didn’t notice it.
Now, to fix this issue, we have the following simple Powershell Command to get all services that are currently not running or stopped:
1
Get-Service | Where-Object {$_.Status -ne 'Stopped' -and $_.Status -ne 'Running'}
When you run this simple one-liner, you get all services that are basically misbehaving and you would like to be reported on. To get this into a simple script for N-Central, you get the following:
1
2
3
4
5
6
7
8
9
10
11
$TwilightServiceNames = ""
$TwilightServices = Get-Service | Where-Object {$_.Status -ne 'Stopped' -and $_.Status -ne 'Running'}
if ($TwilightServices.Count -gt 0)
{
foreach ($TwilightService in $TwilightServices)
{
$TwilightServiceNames += $TwilightService.DisplayName + "; "
}
$TwilightServiceNames = $TwilightServiceNames.Substring(0, $TwilightServiceNames.Length -2)
}
$TwilightServiceCount = $TwilightServices.Count
Download AMP for direct import into N-Central: GitHub
Download PS1 file: GitHub