Reply to comment

Sending an Email When an Event Happens (Windows Server and Powershell)

So... we got these servers a couple years ago, and the event logs don't email me things anymore. It was one of those things that I forgot to check because it's something you just don't check, but it's important. I ended up seeing the alerts late. No harm - no foul, but it still sucks.

The problem is, the latest Windows servers don't have a built-in feature to email events from the event log. The fix is to run a PowerScript script to send the message.

You can also just paste in the command to execute, but I prefer to run a script.

This shows you how to set up a task from within the Event Log viewer. The emailing part is obsolete:
http://www.orcsweb.com/blog/mark-newnam/sending-windows-event-logs-by-email/

Instead, you run a script to send the message. To run scripts, you need to enable script execution on the machine. I set the permission to RemoteSigned for the LocalMachine.
https://technet.microsoft.com/en-us/library/hh847748.aspx

This is an elaborate script that sends a message, but it's not what I'm using:
http://sharepointjack.com/2013/powershell-to-send-an-email-when-something-happens-in-the-event-log/

What I'm using is attached. It accepts a single command parameter so that each message can be customized just a little bit, to give the reader a clue:
http://stackoverflow.com/questions/2157554/how-to-handle-command-line-arguments-in-powershell

My email address is hard coded in the script attached, so you'll have to edit it before using it. I installed it in C:\Users\Public\Bin\

AttachmentSize
sendalert.ps1401 bytes

Reply

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

2 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.