Powershell output column width Powershell output column width powershell powershell

Powershell output column width


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)


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

out.exe | out-file -width 132 -filePath $file


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

enter image description here