Prof. Powershell

PowerShell Screen Buffer Size: Sometimes More Is Better

Here's how to handle command lines that are a lot longer than your display is set for.

If you are new to PowerShell, chances are you are new to the command line world as well. One thing you have probably run into is that some commands return a lot of information, often scrolling right off the screen. Let me give you some tips on how to handle this.

The first thing I always do is increase the screen buffer. On an open PowerShell session, right-click the upper left corner and select Properties. Select the Layout tab. Change the height of the screen buffer size as I've done in Figure 1 and click OK.

Invoke-WebRequest cmdlet

Figure 1. (Click image to view larger version.)

I generally set it to something over 1000, but you can experiment with a value that works for you. This value controls how far you can scroll vertically after a command has finished running. The larger the number, the further you can scroll before data is overwritten.

The next step you can take is to use the More command. This is a legacy command line tool that in essence "pages" the output once screen at a time. The usual technique is to run your command and pipe it to More.

PS Scripts:\> get-process | moreg

At the end of each page is a break.

… 398 19 4796 11920 107 1.59 1628 OpenDNSUpdater 143 8 3196 10980 46 2.93 4896 OSPPSVC 767 73 176020 197744 820 29.23 4192 powershell -- More --

Pressing the Space bar will advance to the next page. Pressing Enter will advance one line of data at a time. Or you can use one of these options.

  • P You will be prompted for the next X number of lines to advance
  • S Skip the next X number of lines
  • F Display the next "file" or page of data
  • Q Quit

More was originally intended as a way to page through large text files. And you can still use it that way. Both of these commands will have the same effect.

PS Scripts:\> more C:\windows\WindowsUpdate.log
PS Scripts:\> get-content C:\windows\WindowsUpdate.log | more

In PowerShell, the More command is actually a function that wraps around more.com. The "real" command has a few more features you can take advantage of as long as you pipe your expression to More.com.

PS Scripts:\> get-wmiobject win32_computersystem | select * | more.com

You might want to use these options:

  • C Clear the screen
  • +N Start at line N
  • S Try to merge blank lines into one

PS Scripts:\> more.com /c /S +10 c:\work\demo.txt

This will attempt to start at line 10 of demo.txt after clearning the screen and attempting to squeeze blank lines together. If you want to learn more, ask for command help:

PS C:\> more.com /?

So the next time you feel overwhelmed with data, take it a little bit at a time with More.

 

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025