GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Email when a service falls over

Home Forums Scripting General Scripting Email when a service falls over

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    jwc1972
    Member
    #157866

    Hello

    I mod this scripts to check an service on a remore computer, This scripts keeps falling over, Could I somehow get this to email myself?. I have look at the windows server 2008 triggers but did not work eith

    Option explicit
    Dim strComputer,strServiceName

    strComputer = “192.168.1.16” ‘ Local Computer
    strServiceName = “masage200” ‘ K3 Service

    if isServiceRunning(strComputer,strServiceName) then
    wscript.echo “The ‘” & strServiceName & “‘ service is running on ‘” & strcomputer & “‘”
    else
    wscript.echo “The ‘” & strServiceName & “‘ service is NOT running on ‘” & strcomputer & “‘”
    end if

    ‘ Function to check if a service is running on a given computer
    function isServiceRunning(strComputer,strServiceName)
    Dim objWMIService, strWMIQuery
    strWMIQuery = “Select * from Win32_Service Where Name = ‘” & strServiceName & “‘ and state=’Running'”
    Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2”)
    if objWMIService.ExecQuery(strWMIQuery).Count > 0 then
    isServiceRunning = true
    else
    isServiceRunning = false
    end if
    end function[/CODE][CODE]Option explicit
    Dim strComputer,strServiceName

    strComputer = “192.168.1.16” ‘ Local Computer
    strServiceName = “masage200” ‘ K3 Service

    if isServiceRunning(strComputer,strServiceName) then
    wscript.echo “The ‘” & strServiceName & “‘ service is running on ‘” & strcomputer & “‘”
    else
    wscript.echo “The ‘” & strServiceName & “‘ service is NOT running on ‘” & strcomputer & “‘”
    end if

    ‘ Function to check if a service is running on a given computer
    function isServiceRunning(strComputer,strServiceName)
    Dim objWMIService, strWMIQuery
    strWMIQuery = “Select * from Win32_Service Where Name = ‘” & strServiceName & “‘ and state=’Running'”
    Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2”)
    if objWMIService.ExecQuery(strWMIQuery).Count > 0 then
    isServiceRunning = true
    else
    isServiceRunning = false
    end if
    end function[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.