Email alert using PowerShell when a windows service failed

12:25 AM 3 Comments

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

image
In the Run Program below type
C:\Windows\System32\Windows PowerShell\v1.0\PowerShell.exe
In 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

3 comments:

  1. I tried it and did not work.

    & "Send-Mail Message –To jyoukhanis@aap.org -Subject \"Service Failed\" -Body \"Please Action\" -SmtpServer mail.aap.org-From sqlserver@aap.org" Please help.

    ReplyDelete
  2. I tried it and did not work.

    & "Send-Mail Message –To jyoukhanis@aap.org -Subject \"Service Failed\" -Body \"Please Action\" -SmtpServer mail.aap.org-From sqlserver@aap.org" Please help.

    ReplyDelete
    Replies
    1. James Youkhanis
      Can you run powershell in administrator mode and there should be a space before the -From

      Delete

Thank you for your comments

Note: Only a member of this blog may post a comment.