Alternate Get-Service

by Aug 29, 2017

The cmdlet Get-Service has a number of drawbacks. For example, there is no parameter to filter running or stopped services, and the results do not include the service startmode.

WMI can deliver such information. Here is a simple function that gets the most often needed service information:

function Get-ServiceWithWMI
{
    param
    (
        $Name = '*',
        $State = '*',
        $StartMode = '*'
    )

    Get-WmiObject -Class Win32_Service |
      Where-Object Name -like $Name |
      Where-Object State -like $State |
      Where-Object StartMode -like $StartMode |
      Select-Object -Property Name, DisplayName, StartMode, State, ProcessId, Description

}

And this is how you’d invoke the command: below line shows all disabled services with their friendly name and description

 
PS C:\> Get-ServiceWithWMI -StartMode Disabled | Out-GridView 
 

Twitter This Tip! ReTweet this Tip!