Send an Email Alert when SQL Server Agent Service Stops/Fails

Here is how you can setup an Alert to send you an Email when SQL Server Agent Server Stops or Fails.

As a matter of fact you can do this for any Service you want to Alert on.

Open computer management program –> Browse down to Services –> Scroll down on the right hand side to SQL Server Agent Service or the service you want to alert on failure.

Right Click the SQL Server Agent Service and Select Properties, then select Recovery page. Expand the drop down for First failure and Select ‘Run a Program’

At the bottom of the page under Run Program, Type in ‘PowerShell’ in the Program input box.

Copy the entire statement from below and paste into the Command line parameters box, make sure you change the To email, Mail server and from email as per your environment.

-Command ‘Send-MailMessage -To suleman@sqlish.com -Subject \”<Mention ServerName>:SQL Agent Stopped\” -Body \”Please look into the issue; Scheduled Jobs will not run if the SQL Server Agent Service remains stopped.\” -SmtpServer <your mail Server> -From suleman@sqlish.com’

Hit Ok to finish the setup.

To test stop the SQL Server Agent service and look for the email in your mailbox.

This entry was posted in Alert, SQL Server, SQL Server Agent and tagged , , . Bookmark the permalink.

4 Responses to Send an Email Alert when SQL Server Agent Service Stops/Fails

  1. Agoo says:

    This looks to be an excellent and simple solution. Unfortunately I can’t get it to work. I am running Powershell 2.0 and I get the following errors after trying to run.
    Missing expression after unary operator ‘-‘.
    At line:1 char:2

    any help would be appreciated as I think this would work really well

  2. darshansh says:

    I have configured alert as per above. However after stopping agent service I do not get mail alert. I have also used mail alert for job fails on same server,that I get. It seems my mail setup is ok. I donot get any error in event log for this.Please replay me.

    Thanks

Leave a Reply