Adjust buffer and line sizes in PowerShell and CMD

Last update: 03/10/2025
Author Isaac
  • The visible size depends on the buffer, window, and source; adjust the buffer/window first, then the source.
  • Use MODE CON and Properties for quick or persistent changes; Registry allows you to replicate settings.
  • In SAC the buffer is 80x24, page with | more and paste with SHIFT+INSERT to avoid losing output.
  • Windows 10 adds drag resizing, text reflow, and opacity for comfortable working.

Buffer and line wrapping in CMD and PowerShell

When working with the console in Windows, adjusting the screen buffer size and the number of lines in the window can make the difference between a smooth session and an unbearable experience. Furthermore, in remote administration environments (such as serial access with SAC in Virtual machines), knowing how to crop or zoom the console and paginate the output correctly is critical to avoid losing information.

In this guide I tell you, with a direct approach and full of commands, how to set everything up from CMD y PowerShell: since the basic design controls and colors, through the MODE and COLOR commands, to persistence through the Registry, console improvements in Windows 10 and use in demanding scenarios such as Azure VM with SACYou'll also see what the Windows Console API for sizing buffers/windows is all about and how it all fits together with Windows. Bus Terminal.

What is the screen buffer and how it relates to the window

The screen buffer is a grid of character cells (width x height) and each console has an associated window that displays a rectangular portion of that buffer. window cannot exceed the dimensions of the buffer or what the screen allows based on the font size. Therefore, if the window is larger than the buffer, certain operations will fail.

Windows API functions help you understand and adjust these limits: GetConsoleScreenBufferInfo returns buffer size, window position and maximum possible size given buffer/source/screen, while GetLargestConsoleWindowSize calculates the maximum window ignoring the buffer size. To zoom in or out, use SetConsoleScreenBufferSize (changes the buffer size) and SetConsoleWindowInfo (resizes or repositions the window) respecting the restrictions mentioned.

Console Window Configuration

Adjust buffer size and number of lines in CMD

For quick adjustment from the console itself, the command MODE CON It's the classic one: define columns (COLS) and rows (LINES). A typical example would be to set up a compact console with 70 columns and 9 rows: MODE CON cols=70 lines=9. This method affects the window and buffer size in one play.

If you prefer a persistent and granular approach, use the Console Properties (right click on the title > Properties). In the Options tab, activate Quick Edit e Insertion to quickly paste and select text, and set Command History: Buffer Size to 999 and Number of Buffers to 5 (more line retention while scrolling). On the Layout tab, raise the Buffer height (for example, 2500), and adjust the size and position of the window; if you uncheck Let the system position the window, you can set specific coordinates.

To customize reading and aesthetics, choose font and size in the tab Source, and define colors in the Colors tab. From the command line you can also change colors with COLOR and a two-digit hex attribute (background and text). For example: COLOR 0E use black background and yellow text; it is useful for monitoring consoles in dark environments.

If you want certain settings to persist and be applied by default, Windows saves them in the Registry. The most relevant keys: HKCU\Console\ (default) and HKCU\Console\%SystemRoot%_system32_cmd.exe (specific to cmd.exe). You can export/import values ​​such as QuickEdit, ScreenBufferSize, WindowSize, NumberOfHistoryBuffers, WindowPosition o HistoryBufferSize with a .REG to replicate your settings without manual reconfiguration.

In addition, CMD startup supports a Autorun to display messages or run actions every time it is opened. In HKCU\Software\Microsoft\Command Processor creates (or edits) the string value Autorun and assign it for example: ECHO "Bienvenido a la consola"It is ideal for support environments where a greeting or initial prompt is required.

  Fix: Windows Home could not find a driver for your community adapter

A handy trick is to pack settings into a batch. Combine size and color with something like this: @ECHO OFF & mode con cols=46 lines=9 & COLOR 1F & ECHO Variables...This gives you windows with predefined dimensions and colors, perfect for scripts that don't require the entire screen.

Settings with MODE and COLOR

PowerShell and Sizing: What You Can and Can't Do

PowerShell uses the same console engine (conhost.exe) than CMD, so it inherits most of the same behavior: the visible size depends on the buffer, window, and font size. If you adjust these parameters via Properties, you'll see the same effect in PowerShell.

In serial console scenarios with SAC (Special Administration Console), the restriction is greater: the environment imposes a reduced buffer of 80×24 and without scrolling back, so it is advisable to paginate with | more in long commands. To advance, use spacebar (page) or Enter (line). Paste shortcuts also change: on the serial console, paste goes with SHIFT + INSERT.

If you usually ask for a keyboard shortcut for change the font size On the fly, the general path is still Properties > Source. On modern consoles you can resize the window by dragging corners and the output is adjusted with the option Text output adjusted on resize, but there is no universal keyboard shortcut documented in the material we handle here.

Using colors, buffer height, or lines from PowerShell works just as well as from CMD, because they are console properties. To automate consoles with recurring visual parameters, create profiles or scripts that apply FASHION y COLOR at the start of the session, or configure the Window Properties pinned to specific shortcuts.

Using SAC on Windows and Azure: Size Limits and Paging Tricks

On Windows VMs (including Azure), SAC has been present since Windows Server 2003 but is disabled. It relies on sacdrv.sys, the service sacsvr and the process sacsess.exe. When opening a command window in SAC, sacsess.exe lanza cmd.exe within the running OS, and from there you can launch PowerShell, manage services, or tap on network and firewall.

Due to the limited buffer 80x24 without scroll, remember to add | more to any verbose command. To paste into the serial console: SHIFT + INSERTIn long scripts, it's often better to write commands in a local editor and paste them into SAC to avoid short buffer issues.

Useful administration commands in CMD within SAC: enable RDP reg add en HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server and in the policy path if applicable; manage the Remote Desktop service with sc (sc query termservice, sc config, sc start/stop); and touch the net with netsh (show interfaces, force DHCP with netsh interface ip set address ... source=dhcp).

For connectivity diagnostics, ping y telnet (after enabling the client with DISM) are good for a quick test; in modern PowerShell it is better Test-NetConnection (ports included). The DNS resolution It is verified with nslookup o Resolve-DnsNameIf you suspect the Firewall, you can list specific rules or temporarily disable profiles with netsh advfirewall set allprofiles state off and reactivate with ... on (do not stop MPSSVC or BFE or you will lose connectivity completely).

For local accounts, in CMD: net user /add, net localgroup Administrators <usuario> /add, net user <usuario> /active:yes. In PowerShell: New-LocalUser, Add-LocalGroupMember y Enable-LocalUser (in earlier versions uses WMI). It is useful to know the SID of the built-in administrator account (S-1-5-21-*-500).

  Find out how to fix Urlmon.dll is missing or undiscovered error

Event Log: In CMD, wevtutil qe allows you to filter by level, provider and time interval with XPath (examples with EventID=11 or audit 4624); in PowerShell, Get-WinEvent -FilterXPath y -MaxEvents It's all the same to you with better formatting. To list software, wmic product It works (watch out for the impact); in PowerShell you can also check WMI and uninstall with .Uninstall().

System integrity: sfc /scannow y dism /online /cleanup-image /scanhealth detect damage; permits NTFS icacls to export/save/restore ACLs, and take ownership with takeown if necessary. Cleaning non-existent PNP devices with RUNDLL32.exe ... pnpclean.dll,RunDLL_PnpClean /Devices /Maxclean. Force policy update with gpupdate /force. Restart with shutdown /r /t 0 (o Restart-Computer -Force).

Using SAC and remote administration

Resize by pixels vs. by columns/rows

A common misunderstanding is wanting to fix a window to 600 × 125 pixels exact from PowerShell. The classic console is designed by columns/lines and the equivalence to pixels depends on the font and its size. So the reliable way is: 1) choose font/size (Properties > Font), 2) adjust the buffer/window with MODE CON or from the Layout tab, and 3) adjust the position/window if necessary with Properties.

If you need programmatic precision, the native API offers SetConsoleScreenBufferSize y SetConsoleWindowInfo. However, you'll need to keep in mind that the window cannot exceed the buffer and the actual maximum size depends on the screen and source; GetLargestConsoleWindowSize gives you that upper bound without considering the buffer.

In Windows 10, you can drag the corner to resize the window, and with the option to Text output adjusted on resize When enabled, text is wrapped to prevent horizontal scrolling in smaller windows. This behavior is a lifesaver when rearranging consoles on NOC monitors or wall screens.

Console improvements in Windows 10 that help with size

The console gains shortcuts Ctrl (copy/paste as in apps modern), extended keyboard text selection and support for wrap selection between the lines as you would in an editor. In addition, there is content filtering clipboard to convert curly quotes or other unsupported characters, avoiding hassles when pasting.

Another novelty: you can resize by dragging the window; when you do this, the system automatically updates the buffer and window dimensions. For those who edit a lot, activate Output text adjusted when resized It is key, as it rewraps long lines when reducing size.

For aesthetics or overlap with other apps, the tab Colours integrates the control of Opacity between 30% and 100%. At 30% the window becomes practically translucent; it is useful for monitor logs without completely covering support tools.

If you see the box of Using the legacy console enabled, uncheck it to enable these modern features. Many are grayed out while legacy mode is on, so turn it off and reopen the console.

Windows Terminal: Backing up settings and profiles

Windows Terminal centralizes CMD/PowerShell/WSL profiles and their settings live in a settings. json en %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState. Before touching fine adjustments, do backup copying the file to a safe path (for example, D:\Backup) with: copy /y /v %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json D:\Backup.

This JSON can be edited with Notepad; there you can pin font sizes, themes, opacity, colors, and scroll behaviors for each profile, giving you a consistent way to open consoles with the look and size you want without relying on manual clicks every time.

Network and Firewall Operations: Key Commands You'll Be Thankful for on Small Consoles

With small consoles, it is best to use concise commands: Test-NetConnection (PowerShell) resume ping and port testing with -Port; in CMD, install TelnetClient with DISM and test ports with telnet host 80. For DNS: Resolve-DnsName (PS) or nslookup (CMD). It is most effective in windows with few lines and combined with | more in SAC.

  The right way to exchange phrases with emojis in iPhone messages

Firewall: list rules by port with Get-NetFirewallPortFilter in PowerShell (or the COM object hnetcfg.fwpolicy2 on older systems) and controls profiles with Set-NetFirewallProfile. In CMD, netsh advfirewall is still valid. Avoid stopping MPSSVC or BFE, or you'll bring down the entire network.

Services, Logging, and System: Essentials for Remote Sessions

For Remote Desktop Services, PowerShell with WMI (Get-WmiObject Win32_Service) shows you the home account, kind of Boot, path and PID, as well as the state. Change the startup type with Set-Service and dependencies from HKLM\SYSTEM\CurrentControlSet\Services\TermService. Start/stop with Start-Service/Stop-Service.

In Registry situations, PowerShell handles keys with Get-ItemProperty y Set-ItemProperty to check or enable RDP. If a group policy enforces values ​​in HKLM\Software\Policies\Microsoft\Windows NT\Terminal Services, remember that your change may be overwritten by the next policy update.

System Diagnostics: systeminfo y wmic os They give you version, build, installation date, time zone and last boot. For safe mode, bcdedit /enum and filter by safeboot. Immediate restart with shutdown /r /t 0 o Restart-Computer if you are already in PowerShell.

Paging, copying, moving, and searching content: PowerShell productivity

Small consoles force you to type quickly. Get-Content with parameters such as -TotalCount o -Tail helps you see the beginning or end of long files. To concatenate without looping, use gc *.txt -Exclude granben.txt > granben.txt, avoiding including the output file in the input itself.

The channeling (|) multiplies productivity: gc archivo.txt | measure -Line -Word -Character counts lines, words and characters. Select-String (sls) searches for patterns in multiple files with wildcards and gives you context without opening them individually.

Instance metadata in Azure to validate connectivity

On an Azure VM, check the Instance Metadata Service From the guest, test connectivity to Azure services. In PowerShell: $im = Invoke-RestMethod -Headers @{'metadata'='true'} -Uri http://169.254.169.254/metadata/instance?api-version=2017-08-01 -Method GET and then $im | ConvertTo-Json to see osType, vmSize, vmId, name, resourceGroupName or private/public IPs. If this answers, the guest arrives at the Azure host.

Remember that Azure NICs must use DHCP within the guest OS, even with a static IP assigned in Azure. Set the adapter with Set-NetIPInterface -DHCP Enabled or with WMI in older versions.

To check adapters: Get-NetAdapter (or WMI) displays status, description and MAC. Enable with Enable-NetAdapter or the so-called WMI .Enable()These queries are compact and friendly to short-line consoles.

Finally, remember that in SAC sessions with limited buffer, removing PSReadLine Remove-Module PSReadLine Avoid unwanted added characters when pasting blocks of text; check first with Get-Module PSReadLine.

With all of the above you can properly size your console (by buffer and window), keep the output readable, and run administration and diagnostics both locally and remotely with SAC, without losing data.

Mastering buffer, window, and output stream sizes isn't just about convenience: it lets you work faster, position windows on large monitors, and keep support sessions under control even when the environment imposes 80x24 limits. MODE CON, Properties, Registry, Console API, Windows 10 improvements and the discipline of paging with | more, you have everything so that CMD and PowerShell adapt to you and not the other way around.