Scheduling a PowerShell Script with Task Scheduler
Getting the settings right for Task Scheduler can be a challenge when it comes to scheduling PowerShell scripts. Below I outline how you will want to define the action of the task.
For Action you’ll want to set it as Start a Program.
For Program/Script, type PowerShell.
In the Add arguments section, you’ll want to place a .\ and the name of the script. If there are other parameters you need to set, place them here. (eg: .\script.ps1 -mode local)
Start in should be the location where you have the script with a trailing slash. (eg: C:\PowerShell\ )
See the screenshot below for an example.
Be sure that your script also has the right permissions to run. Under your base configuration, you’ll want to run local scripts as SYSTEM. For scripts that have to use domain resources, be sure the account defined is only used to run services or scripts and has the appropriate permissions needed whether through local policy or group policy.
Here is how I configured the sample script in my environment:
Is there something different that worked for you? Mention it in the comments below!