Powershell – How to redirect PowerShell output when run from Task Scheduler

line-endingspowershellscheduled-tasks

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 it's not clear if they reached the most appropriate solution in the end. I'm interested if anyone on Stack Overflow has also solved this problem, and how they did it?

Best Answer

I use the transcript feature to help with this. Just include it in your code and it outputs all (would be) screen content to a log file.

Start-Transcript -path $LogFile -append

<Body of the script>

Stop-Transcript
Related Topic