Search code examples
windows-7powershellcommand-linehttp-redirectword-wrap

Commandline syntax to prevent wrapping in PowerShell output file?


The following command wraps the output to the width of the window from which the script was called. That is, the output file is "word"-wrapped. How can I prevent this wrapping in the output file w/o modifying the script?

PS C:\Users\User1> & '\\fileServer\c$\PowerShell Scripts\herScript.ps1' > output.txt

Solution

  • Try this (I can't test it)

    & '\\fileServer\c$\PowerShell Scripts\herScript.ps1' | out-string -width 4096 | out-file c:\output.txt