Cannot Clear All Scrollback Buffer Output from a Remote PSSession In Powershell #4728

Closed
opened 2026-01-30 23:55:05 +00:00 by claunia · 3 comments
Owner

Originally created by @KevOtt on GitHub (Oct 30, 2019).

Environment

Windows build number: 10.0.18362
Windows Terminal version (if applicable): 0.6.2951.0
Powershell Version: 5.1.18362.145

Steps to reproduce

Enter a PS Session, run some command that will cause the output to scroll past the bottom of the terminal window (for example, Get-Process), exit the PS Session, enter "clear" or "clear-host", then scroll up. Part of the output from the command run in the PS Session will still be present in the scrollback buffer and cannot be removed or cleared without closing the tab.

Example in code:

Enter-PSSession 1.1.1.1
for($i = 0; $i -lt 150; $i++){write-host $i} 
exit
clear-host
#scroll up in the terminal window

The attached screenshot shows the contents of my scrollback buffer after running similar code and then running a clear-output command. You can see the output of the commands and the numbers 0-13 present in the scrollback buffer, as in my particular case the code caused the output window to scroll down 15 lines while in the PS Session. At this point clear and clear-host will not be able to remove these 15 lines of output from the Scrollback Buffer.

Windows Terminal Powershell Remote Session Bug

Oddly enough it seems the issue is the same even if you run a "clear-host" while still inside of the PS Session. But running a "clear-host" while inside the PS Session does work as long as the output hasn't caused the terminal window to scroll.

Expected behavior

Entering a "clear" or "clear-host" command in PowerShell should clear the terminal window, including clearing the scrollback buffer of all output. This is the functionality of the cmdlet if running from a cmd window, the PowerShell app, and PS ISE.

Actual behavior

When using the Windows Terminal to enter a PS session with another host, if the output from that session causes the terminal output to scroll down, upon exiting that PS Session and running a "clear" or "clear-host" command will not clear the first portion of the output from the PS session, equal to the number of lines that the ps session caused the window to scroll down.

Other notes

I've tested this with PowerShell 5.1 in Windows 10 from the PowerShell app, cmdhost running powershell, and from PS ISE , it does not seem to occur in any other circumstances outside of the Windows Terminal, so I'm opening this as a Windows Terminal bug. It's not critical, but pretty annoying if doing remote PowerShell work.

Originally created by @KevOtt on GitHub (Oct 30, 2019). # Environment Windows build number: 10.0.18362 Windows Terminal version (if applicable): 0.6.2951.0 Powershell Version: 5.1.18362.145 # Steps to reproduce Enter a PS Session, run some command that will cause the output to scroll past the bottom of the terminal window (for example, Get-Process), exit the PS Session, enter "clear" or "clear-host", then scroll up. Part of the output from the command run in the PS Session will still be present in the scrollback buffer and cannot be removed or cleared without closing the tab. Example in code: ```PowerShell Enter-PSSession 1.1.1.1 for($i = 0; $i -lt 150; $i++){write-host $i} exit clear-host #scroll up in the terminal window ``` The attached screenshot shows the contents of my scrollback buffer after running similar code and then running a clear-output command. You can see the output of the commands and the numbers 0-13 present in the scrollback buffer, as in my particular case the code caused the output window to scroll down 15 lines while in the PS Session. At this point clear and clear-host will not be able to remove these 15 lines of output from the Scrollback Buffer. ![Windows Terminal Powershell Remote Session Bug](https://user-images.githubusercontent.com/36894453/67905612-f1d09180-fb3f-11e9-93eb-52c66ac894df.png) Oddly enough it seems the issue is the same even if you run a "clear-host" while still inside of the PS Session. But running a "clear-host" while inside the PS Session _does_ work as long as the output hasn't caused the terminal window to scroll. # Expected behavior Entering a "clear" or "clear-host" command in PowerShell should clear the terminal window, including clearing the scrollback buffer of all output. This is the functionality of the cmdlet if running from a cmd window, the PowerShell app, and PS ISE. # Actual behavior When using the Windows Terminal to enter a PS session with another host, if the output from that session causes the terminal output to scroll down, upon exiting that PS Session and running a "clear" or "clear-host" command will not clear the first portion of the output from the PS session, equal to the number of lines that the ps session caused the window to scroll down. # Other notes I've tested this with PowerShell 5.1 in Windows 10 from the PowerShell app, cmdhost running powershell, and from PS ISE , it does not seem to occur in any other circumstances outside of the Windows Terminal, so I'm opening this as a Windows Terminal bug. It's not critical, but pretty annoying if doing remote PowerShell work.
claunia added the Resolution-Duplicate label 2026-01-30 23:55:05 +00:00
Author
Owner

@j4james commented on GitHub (Oct 31, 2019):

This sounds like a duplicate of #3126, which in turn has been resolved as a duplicate of #2715.

@j4james commented on GitHub (Oct 31, 2019): This sounds like a duplicate of #3126, which in turn has been resolved as a duplicate of #2715.
Author
Owner

@zadjii-msft commented on GitHub (Oct 31, 2019):

@j4james That sounds right to me, thanks for the early triage!

/dup #2715 #3126

@zadjii-msft commented on GitHub (Oct 31, 2019): @j4james That sounds right to me, thanks for the early triage! /dup #2715 #3126
Author
Owner

@ghost commented on GitHub (Oct 31, 2019):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Oct 31, 2019): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4728