When running a simple PowerShell script from Task Scheduler, I would like to redirect the output to a file.
There is a long thread about this very topic here, yet i
PowerShell 3 onwards allows individual streams (out, verbose, and error) to be redirected. However, Task Scheduler does not understand them. It's PowerShell that does the redirection.
@cmcginty's solution halfway works, since PowerShell is invoking PowerShell. It only supports standard streams (error and out). If you want to use all streams you need to use:
Program or script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Argument: -windowstyle minimized –NonInteractive –NoProfile -c "powershell -c path_to_ps1.ps1 4>>verbose.log 5>>debug.log"
Start in: path_to_ps1