Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Find Required Services with PowerShell

Posted on June 27, 2012

Here's a little PowerShell tidbit to get the status of all the required services. That is, the services that other services depend upon. When using Get-Service, this is the RequiredServices property which will be a collection of service objects.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!


get-service | where {$_.status -eq "running"} | select -expand RequiredServices

I'm intentionally omitting and results so that you can try these command out for yourself. Next we need to filter out the duplicates. You might think this would work:


get-service | where {$_.status -eq "running"} | select -expand RequiredServices | select Name -unique | sort name

And it does, but the selection is case-sensitive and you'll see that some names are a mix of cases. If you just want a list of names, then this will work:


get-service | where {$_.status -eq "running"} | select -expand RequiredServices | select DisplayName -unique | sort Displayname

But I want to also see the status of the required services so I can see if any are not running. I need to use the service name because some of the required services are kernel level and Get-Service won't retrieve them by their displayname. So the challenge comes back to the case issue with the service name. The answer of course is to make them all the same case.


get-service | where {$_.status -eq "running"} | select -expand RequiredServices | foreach {$_.name.tolower()} | sort | get-unique | get-service

I turn each service name into lower case, sort because I like organized results, get the unique names and then pipe each name back to get-service. If I wanted to I could pipe this to Where-Object to only get stopped services or display other information for these required services.

This is a pretty cool example of using the PowerShell pipeline because I'm starting and ending with Get-Service and processing objects through the pipeline to meet my objective, without any scripting or text parsing.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

7 thoughts on “Find Required Services with PowerShell”

  1. Johan Lander says:
    June 27, 2012 at 10:42 am

    Hi
    How do i list all service that is disable ?

    1. Jeffery Hicks says:
      June 27, 2012 at 11:22 am

      For that you’ll need to use WMI:
      Get-WMIObject Win32_Service -filter “StartMode=’Disabled'”

      1. Johan Lander says:
        June 29, 2012 at 3:26 am

        thanks !!

  2. walid Toumi says:
    June 28, 2012 at 8:31 am

    hi

    another variant


    Get-WMIObject -Query "Select * From Win32_Service Where StartMode='Disabled'"

  3. Matt says:
    June 28, 2012 at 11:28 am

    Is it possible to get the status of the depenance services i.e. responding or not? I guess I could search through the entire list.

  4. Matt says:
    June 28, 2012 at 11:42 am

    Ah Jeffery I got so excited I read the blog again and I see you answered my question. I aopologize.

  5. Pingback: Gene Laisne's blog

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d