Home » System Center Operations Manager 2007 » Check StartMode = “Auto”


Welcome to contoso.se! My name is Anders Bengtsson and this is my blog about Azure infrastructure and system management. I am a senior engineer in the FastTrack for Azure team, part of Azure Engineering, at Microsoft.  Contoso.se has two main purposes, first as a platform to share information with the community and the second as a notebook for myself.

Everything you read here is my own personal opinion and any code is provided "AS-IS" with no warranties.

Anders Bengtsson

MVP awarded 2007,2008,2009,2010

My Books
Service Manager Unleashed
Service Manager Unleashed
Orchestrator Unleashed
Orchestrator 2012 Unleashed
Inside the Microsoft Operations Management Suite

Check StartMode = “Auto”

I have seen a lot of questions about checking all services that are configure to start automatically. This can be done with a script. This script checks if the service is configure to start automatic, if it is and it is not running, a warning event will be written in the local application log. You can then pickup that event with Operations Manager and generate an alert.

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

Set colListOfServices = objWMIService.ExecQuery _
        (“Select * from Win32_Service”)

For Each objService in colListOfServices

If (objService.StartMode = “Auto”) and (objService.State = “Stopped”) then

Set objShell = CreateObject(“Wscript.Shell”)
objShell.LogEvent EVENT_WARNING, _
 “Service ” & objService.DisplayName & ” is not running. (” & objService.Name & “)”
End If

Remember to test scripts in a test environment first.