Tuesday, November 22, 2011

How to find “Stopped” windows Services, whose start up mode is set to “Automatic” using PowerShell.

I called these services as “Problematic services”. The start-up mode of these services are “Automatically” so that whenever windows starts or reboot these services should start automatically.
So logically if any of windows services start mode is set to “Automatic” then the Window Service should be running not “stopped”
we are using WMI query language to find these “Problematic Services”
Cmdlet use: Get-WmiObject, Where-Object , Select-Object, Format-List
we are using Win32_Service WMI call to retrieve the list  and status of the services.
   1: Get-WmiObject win32_Service

above command will show the list of all windows services.


Let’s check the all properties of a single “Service”

Get-WmiObject win32_Service  | select -First 1 | fl *

we are piping the result of “Get-WmiObject win32_service” to select-Object cmdlet and choosing -first 1 single Service and then piping further to “Format-List” cmdlet and using * wildcard to show everything.

In below properties we are interested in Name,Status, StartMode, and State property of services.

Get-WmiObject win32_Service  | where {$_.StartMode -eq "Auto" -and $_.State -eq "stopped"}

we are piping the previous command to Where-Object cmdlet and filtering to show  only those services whose “StartUp” mode is “Automatic” and “Status” is “Stopped”

oh!!! we have three problematic services. Okkk!!!


Let’s filter a little bit more
Get-WmiObject win32_Service  | where {$_.StartMode -eq "Auto" -and $_.State -eq "stopped"} |  Select Name,StartMode,State

now we are piping all the previous command to Select-Object cmdlet and choose to show only Name, StartMode, and State property.

Now it seems little bit formatted.

Now you can start these service manually .



Aman Dhally

1 comment:

  1. This comment has been removed by the author.