'''''''''''''''''''''''''''''''''''''''''''''''
'This script checks the MOM serices for all '
'servers in the domain. If the service '
'is in a Stopped state, this will start the '
'service. Server must be listed in the array '
'''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim objWMIService, objItem, objService, strServiceList
Dim colListOfServices, strServer, strService, arrServers
arrServers = Array("server1", "server2")
On Error Resume Next
For Each strServer In arrServers
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strServer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service ")
For Each objService in colListOfServices
If objService.name ="MOM" then
strServiceList = strServiceList & _
strServer & vbCr & objService.Name _
& vbCr & objService.State
If objService.State = "Stopped" _
Then objService.StartService()
End if
Next
Next