Monday, June 10, 2013

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 -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’
Hit Ok to finish the setup.
To test stop the SQL Server Agent service and look for the email in your mailbox.
Post a Comment

Find a cool free stuff everyday

Giveaway of the Day

Hiren Bharadwa's Posts