Listing 1: IdentifySQLComputers.vbs Const ForReading = 1 strInputFile = "C:\Scripts\Computers.txt" strServiceName = "MSSQLSERVER" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextStream = objFSO.OpenTextFile(strInputFile, ForReading) arrComputers = Split(objTextStream.ReadAll, vbCrLf) objTextStream.Close Set StdOut = WScript.StdOut Set objShell = CreateObject("WScript.Shell") On Error Resume Next For Each strComputer In arrComputers ‘ BEGIN CALLOUT A Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer) strPingResults = LCase(objScriptExec.StdOut.ReadAll) ‘ END CALLOUT A If InStr(strPingResults, "reply from") Then ‘ BEGIN CALLOUT B Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2") If Err.Number Then StdOut.WriteLine "ERROR: " & strComputer & " [WMI connection failed]" Err.Clear Else Set objService = objWMIService.Get("Win32_Service.Name='" & _ strServiceName & "'") If Err.Number Then StdOut.WriteLine "GOOD: " & strComputer & _ " [MsSqlServer service NOT found]" Err.Clear Else StdOut.WriteLine "BAD: " & strComputer & _ " [MsSqlServer service FOUND]" End If End If ‘ END CALLOUT B ‘ BEGIN CALLOUT C Else StdOut.WriteLine "ERROR: " & strComputer & " [Ping failed]" ‘ END CALLOUT C End If Next