Windows Server 2008 R2 – How to Get Eventlog Information in a Scheduled Task Email

task-schedulerwindows-server-2008-r2

I have a scheduled task that sends a email when something happens on a application.
Now I want to send the message details of the event also in the email. How to do that?

In Windows Server 2008 R2 with the Task Scheduler.

Best Answer

The only way to accomplish this is a bit of a workaround (in my opinion). You will need to create two actions for your task. The steps are as follows:

  1. Event is triggered
  2. The first action runs a query for the event details you're interested in and saves them to a file.
  3. The second action attaches the event details saved in Step 2 to an e-mail and sends it off.

The process is detailed here: http://blogs.technet.com/b/jhoward/archive/2010/06/16/getting-event-log-contents-by-email-on-an-event-log-trigger.aspx