On Error Resume Next
Set ObjShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ObjInputFile = fso.OpenTextFile("c:\Machines.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("c:\Result.xls", 2, True)
ObjOutputFile.WriteLine "Server Name " & vbTab & "Is Agent Present"
Do While ObjInputFile.AtEndOfLine <> True
strComputer = ObjInputFile.Readline
WScript.Echo "Working on --> " & strComputer
Set objScriptExec = objShell.Exec("Ping -n 2 -w 1000 " & strComputer )
strPingResults = LCase(ObjScriptExec.StdOut.ReadAll)
If InStr(strPingResults,"reply from") Then
Set ObjWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
Set ColService = ObjWMIService.ExecQuery("SELECT * FROM Win32_Service
WHERE Name =' Alerter'")
If ColService.Count = 0 Then
ObjOutputFile.WriteLine strComputer & vbTab & "NO"
End if
For Each Service In ColService
ObjOutputFile.WriteLine strComputer & vbTab & "Yes"
Next
Else
ObjOutputFile.WriteLine strComputer & vbTab & "Unable to Conenct the Server
Or the Server Down"
End if
Loop
WScript.Echo " script Completed"
My Favourite Videos
Wednesday, January 16, 2008
CHECK FOR A PIRTICULAR SERVICE IS AVAILABLE OR NOT And PIPING OUT THE RESULT IN A EXCEL FILE
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment