Powershell can't see "stopping" service?

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

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

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

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.

Don: thank you