Setting up email alerts is simple once you know how to set up the execution of a PowerShell script. This is not very intuitive and took some playing around for me personally when I was first learning. I have included this brief summary on how to set up a task that executes a PowerShell script in an attempt to centralize the information. If you wish to learn more about the "How To" on setting up a task using Task Scheduler I would recommend this link: https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10
Open Task Scheduler.
This can be done quickly by using the key combination Windows Key + x, M.
This will have opened the Computer Management window as an Administrator. Inside the left hand pane select Task Scheduler. You can also open Task Scheduler from an Administrator PowerShell or CMD session using the command taskschd.msc
Giving the task a name and description is pretty self explanatory stuff. Name the task something that helps you to identify what it is. The description is optional.
The user you select the task to "run as" should be someone who has "Run as batch job" permissions. The SYSTEM account can also be configured to run as task with elevated privileges. This is great for cases where the task is triggered by an event in the event log and sending an email afterwards.
If the PowerShell script you are running is doing anything to access files on a network share; or contacting remote devices or websites; the task execution will fail with the SYSTEM account. This is because the SYSTEM account is not allowed those permissions.
I have really only included all the previous information to get to this section.
When running a PowerShell script as a "task action", the following values are appropriate to configure the execution of a program.
Program/Script Field: powershell.exe
Add Arguments: -NoLogo -NonInteractive -WindowStyle Hidden .\FileName.ps1
Start In: C:\Users\Public\Documents
Once those values are set and the rest of your settings are set up as desired, save your task. If you have defined a user that has "Run as batch job" permissions you will need to enter the password for that user in order to save the task.
Copyright © 2020 OsbornePro - All Rights Reserved.
DISCLAIMER: This suite nor any other security suite or tool can completely prevent or detect all security vulnerabilities. This tool adds monitoring to an environment and may not catch every possible scenario and is no guarantee of discovery.
Questions or Comments: email@example.com