How to redirect Powershell output from a script run by TaskScheduler and override default width of 80 characters
Did you try
| Out-File C:\Log\output.log -width 120 # or whatever size you need
Scripting Guy to the rescue!
Link: How can I expand the width of the Windows PowerShell Console
This worked for me:
# Change the PS host parameters, so that log file width is wider than 80 characters$PSHost = Get-Host$PSWindow = $PSHost.UI.RawUI$PSBuffer = $PSWindow.BufferSize$PSBuffer.Height = 3000$PSBuffer.Width = 150$PSWindow.BufferSize = $PSBuffer$PSBuffer = $PSWindow.WindowSize$PSBuffer.Height = 50$PSBuffer.Width = 150$PSWindow.WindowSize = $PSBuffer
I had a very similar situation, and neither of the other answers worked for me. The only way I was able to get it to work was to use the mode
command:
mode con cols=120& C:\path\to\app.exe parameter1 parameter2 | Out-File 'C:\path\to\file.txt' -Encoding Utf8