Featured Article Windows Server Create a script to e-mail service failure notification
Sooner or later, whether you are troubleshooting a server or just managing one, knowing when a particular service goes down can be a real lifesaver. Early notification can help you recognize when a problem has occurred and let you get to work on the problem as soon as possible to minimize disruption to users and/or customers.
The properties for a service provide for a handful of recovery options. To view these properties, open the Services console, double-click a service, and then click the Recovery tab.
Three drop-down lists on the Recovery tab enable you to specify what action Windows should take, if any, when the service fails the first, second, and subsequent times. If you want to receive an e-mail notification when the service goes down, create the following script using Notepad:
set objArgs = Wscript.Arguments
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "adminaddress@yourdomain.tld"
objEmail.To = "youraddress@yourdomain.tld"
objEmail.Subject = objArgs(0) & " service is down"
objEmail.Textbody = "The service " & objArgs(0) & " has failed."
objEmail.Send
set objArgs = nothing
set objEmail = nothing
Save the script as Mail.vbs, then open the properties for the service from the Services console. In one of the three drop-down lists, choose the option Run a File. Click Browse to browse for and select the Mail.vbs script you just created. In the Command Line Parameters field, type the service name (without spaces) that you want passed to the script. Then, click OK. |