Author Posts

July 31, 2017 at 6:14 pm

I see in services.msc I have a service that has a status of "Stopping" and is hung there, so my agent is effectively not working. I wish to to Kill and re-start this service and had attempted to execute

Get-Service | where-object { $_.status -eq "Stopping" }

...but I come up empty handed.

Any other ideas to identify this rogue service, stop it then re-start it?

thanks

July 31, 2017 at 6:16 pm

Have you tried querying Win32_Service instead? Curious if the result is different.

July 31, 2017 at 7:04 pm

Found it.

re: STATUS

.msc displays one name ("Stopping"), Get-Service displays another ("StopPending") and Get-WmiObject displays a third ("Degraded")

In order to find the "Stop Pending" with Get-WmiObject, I would have had to search against State (not Status)

Get-WmiObject Win32_service | Where-Object { $_.Name -like 'NP*' }


ExitCode  : 0
Name      : NPSrvHost
ProcessId : 2420
StartMode : Auto
State     : Stop Pending
Status    : Degraded

July 31, 2017 at 7:42 pm

Under the hood it's a numeric value, so different interfaces interpret it into different English strings. That's why. And yes, WMI exposes it as State, not Status.

July 31, 2017 at 7:46 pm

Don: thank you