Wednesday, September 22, 2021

Execute PowerShell in Windows Scheduled Task

 There are many ways to execute PowerShell in Windows scheduled tasks:

Option #1

Program/Script: PowerShell.exe

Add arguments (optional): -command "& {& 'C:\path\to\script.ps1'}"

Start in (optional): C:\path\to\

Option #2

Program/Script: PowerShell.exe

Add arguments (optional): -NonInteractive -Noprofile -File "C:\path\to\script.ps1"

Start in (optional): C:\path\to\

Option #1 allows me to have the script to connect to the Internet (server is located behind corporate proxy).