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.
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.
Hi
How do i list all service that is disable ?
For that you’ll need to use WMI:
Get-WMIObject Win32_Service -filter “StartMode=’Disabled'”
thanks !!
hi
another variant
Get-WMIObject -Query "Select * From Win32_Service Where StartMode='Disabled'"
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.
Ah Jeffery I got so excited I read the blog again and I see you answered my question. I aopologize.