Monthly Archives: April 2017

QuickTip: Change PowerShell Console Size and Buffer

Changing the size of the PowerShell console is something that has been made easier in recent versions of PowerShell. But when working with older versions of PowerShell or with automated systems it is useful to be able to do this programmatically.

To set the buffer to 5000 lines and a line width of 160 characters we run the following code:

1
$host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(160,5000)

To determine the current width and buffer of the console we can check the following variable:

1
$host.UI.RawUI.BufferSize

Note that when you attempt to decrease the width to below the current width you will be presented with an error:

Share