If I have an executable out.exe and it's stdout is redirected to a file, i.e.:

out.exe > $file

Right now if I do this it only outputs:

80 columns per line to the file

Is there a way to make the standard output to be wider in console column count? Is it the out.exe that's somehow messing with the columns? In my case I'm using fxcopcmd.exe.

  • 1
    I want to update this question. It turns out that im trying to output to Visual Studio Output window.. but the windows it wrapping at 80 charachters.. is there any way to set it to wider? – maxfridbe Jun 11 '09 at 16:50

I encountered a similar problem a while back. Here's what I did to fix it:

# Update output buffer size to prevent clipping in Visual Studio output window.
if( $Host -and $Host.UI -and $Host.UI.RawUI ) {
  $rawUI = $Host.UI.RawUI
  $oldSize = $rawUI.BufferSize
  $typeName = $oldSize.GetType( ).FullName
  $newSize = New-Object $typeName (500, $oldSize.Height)
  $rawUI.BufferSize = $newSize

It simply sets a new width of 500 characters on the host's RawUI output buffer (though, since we run our build in several environments, and we did not want the script to fail just because it could not make the output a bit larger, the code is rather defensive).

If you run in an environment that always sets RawUI (and most do), the code can be greatly simplified:

$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 25)
  • 1
    Thank you.. You sir are the man! – maxfridbe Jul 24 '09 at 17:55
  • 1
    Be careful when setting the size as setting one of the dimensions to a smaller value will cause the script to bork. This older blog post on the topic caused me some head-scratching - weblogs.asp.net/soever/archive/2008/12/09/… (FWIW my comment is near the bottom) – Chris Oldwood Mar 23 '12 at 9:24
  • 1
    I used the full solution in a TFS post-build script, for a build using the new TFS 2012 templates. It worked exactly as advertised. Thank you! – JamesQMurphy Jun 15 '15 at 17:02
  • 1
    I lived with artificially wrapped log files for far too long. Thanks. – Nick Aug 8 '16 at 18:31
  • 1
    @kkuilla Ask a new StackOverflow question :) But I will tell you that you can do it by setting up your own PowerShell profile – JamesQMurphy May 2 at 21:05

Both the out-file and out-string cmdlets have a width parameter:

out.exe | out-file -width 132 -filePath $file
  • 5
    But this won't help if the exe is deciding to only output 80 characters. – JasonMArcher Jun 16 '09 at 21:43

If you're talking about Windows PowerShell - just open "properties > Layout" increase buffer size + window size

enter image description here


In my powershell script I set the first line to not do carriage returns the second line I manually did a return.

(within a loop)

Write-Host -nonewline "$var1;$var2"

Write-Host "`r"

That overrode the issue with having my line wrapped but still doing a return after each individual record.

  • 1
    I believe the issue at hand is to increase the width of the output window in VS.... this doesn't seem like it answers the question properly. – rayryeng May 9 '14 at 2:32

Your Answer

