+ Post New Thread
Results 1 to 2 of 2
Windows Server 2012 Thread, Task Scheduler - Send an email in Technical; I've just discovered that the ability to send an email based on an event, or a task has been deprecated. ...
  1. #1

    Join Date
    May 2007
    Location
    Kent
    Posts
    125
    Thank Post
    39
    Thanked 11 Times in 10 Posts
    Rep Power
    28

    Task Scheduler - Send an email

    I've just discovered that the ability to send an email based on an event, or a task has been deprecated. I've always found this quite useful for spotting when backups fail, or when syncs have happened etc..

    A quick google search does not give any reason why Microsoft have decided to drop this functionality, nor can I find if there is now an alternative recommended way of getting a notification based on a event.

    Anyone found a way? I'm guessing it may be too early to ask a question like this!

  2. #2

    Join Date
    Sep 2012
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Server 2012 task scheduler email

    Here's a quick little powershell script that does it for me. I set up event viewer to run it on the administrative events filter.
    #Get the app log minus the annoying warnings from MSCVCR that occur because I don't own my domain/tree.
    #Only grab the previous 2 minutes - this could probably be shortened.
    $logapp = get-eventlog -LogName Application -after ([DateTime]::Now.AddMinutes(-2)) -EntryType Warning,Error | where-object {$_.EventID -ne 12339 -and $_.EventID -ne 12344} | fl | out-string

    #Get the system log -- only warnings & errors
    $logsys = get-eventlog -LogName System -after ([DateTime]::Now.AddMinutes(-2)) -EntryType Warning,Error | fl | out-string

    #Grab the hardware log (everything)
    $loghrd = get-eventlog -LogName HardwareEvents -after ([DateTime]::Now.AddMinutes(-2)) | fl | out-string

    #Setup a string to go out in the email
    $x = @"
    Applog $logapp
    Syslog $logsys
    Hardware $loghrd
    "@

    $smtpServer = "smtp.mydomain.edu"
    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SMTPClient($smtpServer)
    $msg.From = "from@mydomain.edu"
    $msg.To.Add("to@mydomain.edu")
    $msg.subject = "MyMachine Syslog"
    $msg.body = $x $smtp.Send($msg)


    Quote Originally Posted by mitchell1981 View Post
    I've just discovered that the ability to send an email based on an event, or a task has been deprecated. I've always found this quite useful for spotting when backups fail, or when syncs have happened etc.. A quick google search does not give any reason why Microsoft have decided to drop this functionality, nor can I find if there is now an alternative recommended way of getting a notification based on a event. Anyone found a way? I'm guessing it may be too early to ask a question like this!
    Last edited by electro_wc; 24th September 2012 at 09:55 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. VB/AutoIt Script Sending An Email
    By russdev in forum Scripts
    Replies: 5
    Last Post: 1st July 2010, 10:45 PM
  2. Sending HTML content via an email contact form
    By AnnDroyd in forum Web Development
    Replies: 2
    Last Post: 10th May 2010, 12:43 PM
  3. Pressing "Return" to send an email??
    By WithoutMotive in forum General Chat
    Replies: 7
    Last Post: 8th November 2008, 10:43 AM
  4. Replies: 9
    Last Post: 10th May 2007, 10:13 AM
  5. Replies: 16
    Last Post: 29th March 2006, 03:52 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •