Powershell can't see "stopping" service?

This topic contains 4 replies, has 2 voices, and was last updated by  Jeff Taylor 2 weeks, 2 days ago.

  • Author
    Posts
  • #76267

    Jeff Taylor
    Participant

    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

  • #76270

    Don Jones
    Keymaster

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

    • #76273

      Jeff Taylor
      Participant

      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
  • #76283

    Don Jones
    Keymaster

    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.

You must be logged in to reply to this topic.