1

I would like to change the default height of the PowerShell screen buffer in Windows 10. (I have not tried to do this on other Windows versions.) It seems like it ought to be very simple.

If I right click on the PowerShell title bar, there’s a “Defaults” option in the contextual menu, and that opens a window with a tab that says “Layout”. Under that tab are screen buffer size options for “Width” and “Height”. So far, so good. There’s a problem, though: PowerShell only respects the default height setting until I restart my computer. Then the actual buffer height of new PowerShell windows is set to the screen height, even though the default seems to remain whatever value I set. How can I set a persistent default value? Perhaps there’s a configuration file of some sort that I should edit instead of using the defaults GUI?

(On a related note that doesn’t make much sense as a separate question, is the behaviour I’m observing intended or should I submit a bug report to Microsoft? It seems odd, but I don’t want to assume it’s a bug right off the bat because a lot of behaviours that I do not understand in popular software products are apparently intended.)

4
  • Try this method and see if it is persistent: $host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(160,5000)
    – Doug Deden
    Commented May 6, 2021 at 19:59
  • 1
    Try setting the same values in Properties as well as Defaults. That works for me on Windows 7.
    – DavidPostill
    Commented May 6, 2021 at 20:08
  • @DavidPostill Setting the Properties value only affects one window at a time, which I’m decently confident is intended behaviour. This has no bearing on the default value that any other PowerShell window uses, which means it does not help with answering the question. I believe the whole idea behind having default settings is to make sure we don’t have to set the value every time, though I do admit I reached that conclusion based on what I think makes sense, which may or may not match up with reality. Commented May 7, 2021 at 2:06
  • @DougDeden That is not persistent, but it is interesting. Commented May 7, 2021 at 2:15

1 Answer 1

4

Put what Doug shows you in the AllUsers PowerShell profile. As of PowerShell 7.1, that means adding $host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(<width>,<height>) to $PsHome/Profile.ps1 for the given <width> and <height> values to apply to all new PowerShell console windows on the machine. This applies to all users and hosts.

How to choose a profile If you use multiple host applications, put the items that you use in all the host applications into your $PROFILE.CurrentUserAllHosts profile. Put items that are specific to a host application, such as a command that sets the background color for a host application, in a profile that is specific to that host application.

If you are an administrator who is customizing PowerShell for many users, follow these guidelines:

Store the common items in the $PROFILE.AllUsersAllHosts profile Store items that are specific to a host application in $PROFILE.AllUsersCurrentHost profiles that are specific to the host application Store items for particular users in the user-specific profiles Be sure to check the host application documentation for any special implementation of PowerShell profiles.

Windows PowerShell Profiles Processing IllustratedDiagram of PowerShell execution flow, including profile loading.

Paths and precedence for PowerShell profile configuration files, beginning with “AllUsersAllHosts” at $PsHome\Profile.ps1

Step 5: Host agnostic profile loads for any logged-on user The AllUsersAllHosts profile script also loads for any user that logs on

Table:
<#
User    Host    Sequence    Shared between hosts    Path
____    ____    ________    ____________________    ____
All     All     1           Yes                     $PsHome\Profile.ps1
All     Current 2           No                      $PsHome\Microsoft.<hostid>_profile.ps1
Current All     3           Yes                     $Home\[My] Documents\WindowsPowerShell\Profile.ps1
Current Current 4           No                      $Home\[My] Documents\WindowsPowerShell\<hostid>_profile.ps1
#>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .