07-21-2023, 05:43 PM
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][1] 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`
[1]:
[@cmcginty's solution][1] 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`
[1]:
[To see links please register here]