Email alert using PowerShell when a windows service failed
You can use Windows PowerShell to send you an email notification when a windows service failed. Here are the steps:
1. Open Windows Services by doing start –> Run –> Services.msc
2. Right Click on the Service and go to Properties and chose Recovery tab
3. Select Run a Program
In the Run Program below type
Click on Apply and OK.
Go to Task Manager and end the Process.
You should receive an email
1. Open Windows Services by doing start –> Run –> Services.msc
2. Right Click on the Service and go to Properties and chose Recovery tab
3. Select Run a Program
In the Run Program below type
C:\Windows\System32\Windows PowerShell\v1.0\PowerShell.exeIn the Command line type the following
& "Send-Mail Message –To visionabove@gmail.com -Subject \"Service Failed\" -Body \"Please Action\" -SmtpServer YOURSMTPSERVER -From visionabove@gmail.com"
Click on Apply and OK.
Go to Task Manager and end the Process.
You should receive an email
I tried it and did not work.
ReplyDelete& "Send-Mail Message –To jyoukhanis@aap.org -Subject \"Service Failed\" -Body \"Please Action\" -SmtpServer mail.aap.org-From sqlserver@aap.org" Please help.
I tried it and did not work.
ReplyDelete& "Send-Mail Message –To jyoukhanis@aap.org -Subject \"Service Failed\" -Body \"Please Action\" -SmtpServer mail.aap.org-From sqlserver@aap.org" Please help.
James Youkhanis
DeleteCan you run powershell in administrator mode and there should be a space before the -From
I had issues with this method to but after a lot of testing was able to get the following method working on my Windows 2016 server.
ReplyDelete1. Set the service recovery to restart on First and Second failures.
2. Set subsequent failures to Run a Program.
3. Set the program to run to be:
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Command "Send-MailMessage -To myteam@test.com -From server@test.com -Subject \"This Service Failed\" -Body \"The Service has failed and there may be issues with this. Please log into the server and troubleshoot the service.\" -Priority High -SmtpServer smtp.test.com
4. Set Reset fail count after to be 1 day and Restart service after 1 minute
Makasih ya infonya bermanfaat.
ReplyDeleteBoleh dong kunjungan balik ke blog saya,
ditunggu di sini ya : https://slashdot.org/submission/13323430/pt-agres-info-teknologi---toko-komputer-online