How To Check Remote And Local Server Services Script

Const strSVCName = “ServicesName

Dim objWMIService, colServices, objService, strComputer

strComputer = “ServerName”

Set objWMIService = GetObject(“winmgmts:” _

& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

Set colServices = objWMIService.ExecQuery(“Select * from Win32_Service WHERE DisplayName = ‘” & strSVCName & “‘”)

For Each objService in colServices

if objService.State = “Running” then

Set objEmail = CreateObject(“CDO.Message”)

objEmail.From = “test@test.com”

objEmail.To = “a@a.com”

objEmail.Subject = “Service Is Down”

objEmail.Textbody = “Service is Unavaible”

objEmail.Configuration.Fields.Item _

(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2

objEmail.Configuration.Fields.Item _

(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = _

SmtpServer

objEmail.Configuration.Fields.Item _

(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25

objEmail.Configuration.Fields.Update

objEmail.Send

Add a Comment

Your email address will not be published. Required fields are marked *