Returning “Automatic” services only in powershell

There are a lot of cases when you might need to check the services on a server and it is a pity that the get-service powershell cmdlet doesn’t return the startup type of a service. That makes it useless for tasks like quickly checking what automatic services are not running on a particular server.

Fortunately WMI calls can solve this issue although it would have been much easier to simply use get-service cmdlet.

Here is a quick example of how to use get-WmiObject to return all services that are set to Automatic startup but are currently not running

Get-WmiObject Win32_Service |
Where-Object { $_.StartMode -eq 'Auto' -and $_.State -ne 'Running' } |
# process them; in this example we just show them:
Format-Table -AutoSize @(
@{ Expression = 'State'; Width = 9 }
@{ Expression = 'StartMode'; Width = 9 }

I have been working in IT consultancy and solution integration since 1998 and I consider myself lucky to be, one in a few, making a living out of my passion. I am also member of the famous Experts Exchange (profile here) online community where I try my best to share what I have learned along the road.

Posted in Randoms Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *