Powershell can't see "stopping" service?

Welcome Forums General PowerShell Q&A Powershell can't see "stopping" service?

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
1 year, 3 months ago.

  • Author
    Posts
  • #76267

    Participant
    Points: 58
    Rank: Member

    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

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

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

    • #76273

      Participant
      Points: 58
      Rank: Member

      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

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    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.

    • #76286

      Participant
      Points: 58
      Rank: Member

      Don: thank you

The topic ‘Powershell can't see "stopping" service?’ is closed to new replies.