Only specific tasks in task scheduler alert on email with error details

vidhi 1 Reputation point
2021-04-10T21:47:21.63+00:00

i have scheduled 3 tasks in task scheduler and i want to see if there is any error in any of the 3 tasks execution and if yes, report back on a mail with the error details as well. Please help in below queries.

(a) Check if the tasks are executed successfully and trigger an email if task execution fails or shows an error.
(b) From application logs gather the number or warning and error alerts generated by WanCapacityRunner and captured for the day and report the same.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-04-12T07:48:33.717+00:00

    Hi,

    You can check the Last Run Results of scheduled tasks using Get-ScheduledTaskInfo and send mail messages using Send-MailMessage
    https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/get-scheduledtaskinfo
    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage

    The Get-WinEvent can filter events from the application logs. This link is helpful for parsing the events.
    https://devblogs.microsoft.com/scripting/use-powershell-cmdlet-to-filter-event-log-for-easy-parsing/

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.