Dear all,
I use this script in GFI Network Monitor - but it didn't work at PRTG. Many thank's for your help.
Patrick
' ///////////////////////////////////////////////////////////////////////////// ' ' ServerServies takes a computer name as an argument and will check that computer ' for all services not in a "Running" state and are set to "Auto" start. There is ' a comma delimited string (strIgnore) that can be used to specify services to ' ignore if they are not "Running" but set to "Auto" start. A good example is the ' Performance Logs and Alerts service. While the string is comma delimited there ' is no requirement for the comma except for logical seperation for the programmer. ' ///////////////////////////////////////////////////////////////////////////// Dim ArgObj, i, objWMIService, colItems, strIgnore, stoppedItem Set ArgObj = WScript.Arguments strComputer = ArgObj(0) On Error Resume Next Dim ' strIgnore is a comma delimited list of "Display Names" of ' auto start services that are known to not be in a running state. ' Display names can be found via the services snap-in or the "net start" ' command in a cmd.exe window. strIgnore = "TSM StorageAgent1,TPM Base Services,Microsoft .NET Framework NGEN v4.0.30319_X64,Microsoft .NET Framework NGEN v4.0.30319_X86,Software Protection,TPM Base Services,Server For NIS,Office Communications Server Monitoring Agent,Internet Connection Sharing (ICS),Security Center,Volume Shadow Copy,Shell Hardware Detection,CONZEPT 16 print processor"+ _ "Performance Logs and Alerts" ' Make a connection via WMI to the argumented remote computer. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") If( Err.Number <> 0 ) Then ServerServices = retvalUnknown wscript.echo = "Unable to access '" & strComputer & "'" wscript.quit("3") End If ' Make a WMI query for Services (on the remote computer) that are set to ' auto start but are not in a Running state. (I.E. stopped, pending... etc.) Set colItems = objWMIService.ExecQuery("select * from Win32_Service " + _ "where State!='Running' and StartMode='Auto'",,48) ' Search the strIgnore string with auto start services that are not running. ' If a non-running auto start service is not in the strIgnore string, then ' fail and return the service name. Note that if multiple auto start services ' are not running only the first one will be listed. For Each stoppedItem in colItems If instr(strIgnore,stoppedItem.Displayname) = 0 Then wscript.quit("1") wscript.echo = "Service Not Started: " & stoppedItem.Displayname Exit End If Next wscript.echo = "All Auto-Start services are in a Running state."&":Ok" wscript.quit("0")
Add comment