{"id":279,"date":"2008-06-14T21:22:06","date_gmt":"2008-06-14T19:22:06","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=279"},"modified":"2008-06-14T21:22:36","modified_gmt":"2008-06-14T19:22:36","slug":"check-startmode-auto","status":"publish","type":"post","link":"https:\/\/contoso.se\/blog\/?p=279","title":{"rendered":"Check StartMode = &#8220;Auto&#8221;"},"content":{"rendered":"<p>I have seen a lot of questions about checking all services that are configure to start automatically. This can be done with a script.\u00c2\u00a0This 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.<\/p>\n<p>strComputer = &#8220;.&#8221;<br \/>\nSet objWMIService = GetObject(&#8220;winmgmts:&#8221; _<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 &#038; &#8220;{impersonationLevel=impersonate}!\\\\&#8221; &#038; strComputer &#038; &#8220;\\root\\cimv2&#8221;)<\/p>\n<p>Set colListOfServices = objWMIService.ExecQuery _<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 (&#8220;Select * from Win32_Service&#8221;)<\/p>\n<p>For Each objService in colListOfServices<\/p>\n<p>If (objService.StartMode = &#8220;Auto&#8221;) and (objService.State = &#8220;Stopped&#8221;) then<\/p>\n<p>Const EVENT_WARNING = 2<br \/>\nSet objShell = CreateObject(&#8220;Wscript.Shell&#8221;)<br \/>\nobjShell.LogEvent EVENT_WARNING, _<br \/>\n\u00c2\u00a0&#8220;Service &#8221; &#038; objService.DisplayName &#038; &#8221; is not running. (&#8221; &#038; objService.Name &#038; &#8220;)&#8221;<br \/>\nEnd If<br \/>\nNext<\/p>\n<p>Remember to test scripts in a test environment first.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have seen a lot of questions about checking all services that are configure to start automatically. This can be done with a script.\u00c2\u00a0This 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 &hellip; <a href=\"https:\/\/contoso.se\/blog\/?p=279\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/279"}],"collection":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279"}],"version-history":[{"count":0,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/279\/revisions"}],"wp:attachment":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}