Automatic StartMode Service Stopped in Windows server : PowerShell Script to List the Servers and List of Service

Posted on: November 28, 2012

I had free time this evening , and I thought of using this time for PowerShell Scripting . So I came up with an IDEA to build a Powershell script which will query the list of servers and get the status of services(windows server) whose StartMode is set as Automatic.

As All of us know (Windows Administrators) , If the startmode of a service is set to automatic , that service has to be in “RUNNING” State ( Even If it screw’s your System 🙂 )

Some times this will not be the case , On Most of the instances if the server is patched and rebooted , some of the Automatic Services will not start.

To determine the servers and list of services , One can use Below PowerShell Code

Get-WmiObject -Class win32_Service -ComputerName (Get-Content C:\Names.txt) | ?{$_.StartMode -match “Auto*”} | Select-Object -Property * | %{ if($_.State -match “stopped”) {‘{0},{1},{2},{3}matic’ -f $_.SystemName,$_.DisplayName,$_.State,$_.StartMode | Out-File C:\AutoMaticServiceStatus.Csv -NoClobber -Encoding ascii -Append }}

Script will produce output C:\AutoMaticServiceStatus.csv in your C:\ Drive

Note – C:\Names.txt contains the Server Names against which we will run this powershell code.

Happy Scripting.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: