I have written the following script using scriptomatic to check for the existence of a specific service where I have substituted my-computer in the array with the actual list of computer names. The script runs as expected and produces the output to a text file. The settings are as follows-
- The WMI Namespace is set to root\CIMV2
- The WMI Class is set to Win32_Service.
- Language is set to VBScript
- Output format is plain text
My problem/question is with the results. I have found a computer that according to the results should have the service running. When I actually verified the service, it does not exist on the computer.(I am checking Win2k3 and Win2k8 servers) I am not sure why. Thoughts? Thanks.
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("my-computer")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service where DisplayName = ""SplunkForwarder""")
For Each objItem In colItems
WScript.Echo "DisplayName: " & objItem.DisplayName
WScript.Echo "Started: " & objItem.Started
WScript.Echo
Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
- Edited by JeremyTourville Tuesday, February 04, 2014 4:49 PM


