Script to find state of service on remote computers
Moderator: DosItHelp
Script to find state of service on remote computers
Can you help me write a script that will tell me if the "Windows Update" service on a several remote computers (list of IP addresses in notepad)
test.vbs
Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSrcFile = objFSO.OpenTextFile("IPlist.txt",1,True)
Do Until objSrcFile.AtEndOfStream
strComputer = objSrcFile.ReadLine
If strComputer <> "" Then
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery ("Select * from Win32_Service Where DisplayName = 'Windows Update'")
For Each objService in colRunningServices
If objService.State <> "Running" Then
Wscript.Echo "The service is not running"
else
Wscript.Echo "The service is running"
End If
Next
End If
Loop