Forum Discussion

Adamzter81's avatar
Adamzter81
Copper Contributor
Jul 31, 2024

Powershell to Monitor Services

Hello,   I have specific services that I would like to monitor on specific servers and send out alert if service is stopped.  Below is a script that works for monitoring one service on a specific s...
  • Harm_Veenstra's avatar
    Harm_Veenstra
    Aug 01, 2024

    #Loop through all servers and services for each server
    foreach ($servername in $servernames)
    foreach ($ServiceName in $ServiceNames) {
    If (Get-Service -ComputerName "$servername" -Name "$ServiceName") {
    $ServiceStatus = Get-Service -ComputerName "$servername" -Name "$ServiceName"
    $ServiceState = $ServiceStatus.Status
    ServiceCheck
    }
    }
    }

    This checks if service is there, then checks status

Resources