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.
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:
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:
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.
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.