#PSTip How to get non-running automatic services

The Startup type information is not available when we use the Get-Service cmdlet. Luckily the Win32_Service WMI class has a StartMode property that we can use to create a nice server-side filter. If outer quotes are double quotes, you need to use single ones for values.

Get-WmiObject -Class Win32_Service -Filter "StartMode='Auto' AND State='Stopped'"

You can add ComputerName parameter to easily query services on a remote computer:

Get-WmiObject -Class Win32_Service -Filter "StartMode='Auto' AND State='Stopped'" –ComputerName Server01,Server02 –Credential (Get-Credential Administrator)

You cannot use the Credential parameter when you run the management operation against the local computer.

About the author: Aleksandar Nikolic

Aleksandar is a PowerShell MVP and a co-founder of PowerShell Magazine. He is a frequent speaker at the conferences and participates regularly in IT Pro user groups worldwide. Recently, Aleksandar co-authored the highly respected Administrator’s Guide to Windows PowerShell Remoting. Follow him on Twitter at @alexandair

Related Posts

%d bloggers like this: