Detect Windows Services


Greetings Professionals,

Does chef has power to detect the services that are running on windows nodes ? for example i need to check on what are all the servers the W3svc services are running? is it possible through chef,- ohai supports this feature?

Please help



Chef is capable working with windows services per:


If you just need to check if a process is running, knife and powershell will be your best bet

knife winrm name:web1 --winrm-user <foo>\\<bar> --winrm-shell powershell '[bool]$(Get-Process -Name w3wp -ErrorAction SilentlyContinue)' 

This returns true if w3wp is running, false if not


Might I also suggest looking into Inspec to check the compliance of your servers with a pre-defined policy (like services)



If your node isn’t in the same network that your workstation, you can use the following ruby code within ruby_block or directly in the recipe:

status = powershell_out!('(Get-Service serviceName).Status')


status = ´powershell.exe (Get-Service serviceName).Status´

to catch the response of script.

I hope that it helps you !



Can you please elaborate im trying to check services running on one of my windows machine 10.0.x.x.x and password *****
correct me if im wrong is this the way to execute the command?

knife winrm name:web1 --winrm-user 10.0.x.x.x*****; --winrm-shell powershell '[bool]$(Get-Process -Name w3wp -ErrorAction SilentlyContinue


Run knife from your workstation where you have knife installed

There should be no semicolon ‘;’ and you are missing a trailing ‘)’