Powershell Tip: Send quick Email when a service goes down [Update: And bring it back up]
Yes we have SCOM monitoring and stuff, but if some testing or debugging is going on and do don’t want to do down the hassle of setting up alerts and just simply want to get notified when a service goes down, here is a simple script
1 2 3 4 5 6 7 8 |
$status = (Get-Service "<ServiceName>").Status while ($status -eq "Running") { Start-Sleep -Seconds 10 } Send-MailMessage -From "<FromAddress>" -To "<ToAddress>" -Body "<Body>" -Subject "<Subject>" -SmtpServer "<SMTPServer>" |
It’s pretty self explanatory. You can also […]