Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Last active December 7, 2021 20:32
Show Gist options
  • Save JohnL4/049badf447e9136607327018f7a8e4b9 to your computer and use it in GitHub Desktop.
Save JohnL4/049badf447e9136607327018f7a8e4b9 to your computer and use it in GitHub Desktop.
Notes on scheduling a PowerShell script with Windows Task Scheduler
The program to run is: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (or wherever the PS executable is on your system)
The arguments are: -NoProfile -File Run-ScheduledScript.ps1
Run-ScheduledScript is where you redirect all your output streams to a log file using the '*>' PowerShell redirect operator
(or some variant thereof).
Maybe "*>&1" to merge everything to the SUCCESS stream, followed by "| Out-File -width 200 -encoding oem" or something equally creative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment