GeezerVison is showing github.com — Fix Clear-Host for remote Windows PSSession by jborean93 · Pull Request #28116 · PowerShell/PowerShell
Conversation
PR Summary
Implements the bare minimum on the local PSHostRawUserInterface used on non-Windows to support the Clear-Host call when targeting a remote Windows host in Enter-PSSession.
PR Context
Fixes: #28115
Note: This does not fix Clear-Host when targeting a non-Windows endpoint, only when targeting a Windows endpoint.
PR Checklist
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
0xfeeddeadbeef reacted with thumbs up emoji
Implements the bare minimum on the local PSHostRawUserInterface used on
non-Windows to support the `Clear-Host` call when targeting a remote
Windows host in `Enter-PSSession`.
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟢 Approval recommended
No unresolved review issues remain.
Review effort: Lite
Findings: None
What changed in this PR
Fixes Clear-Host for remote Windows sessions initiated from non-Windows clients.
Changes:
- Handles the full-buffer clear request.
- Clears the local console with
Console.Clear().
- Preserves unsupported-operation behavior.
| File |
Description |
src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs |
Implements remote Windows Clear-Host support on Unix clients. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
fill.Character == ' ')
|
|
|
{
|
|
|
// Emits the same sequence as the clear command used by the
|
|
|
// local Clear-Host function.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a workaround for Clear-Host only, I believe we need to explicitly check ForegroundColor and backgroundColor too, as set by Clear-Host.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local Clear-Host on non-Windows doesn't check the colors. I think it's fine to ignore the colors here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I wasn't sure if the actual values set remotely would line up with the ones seen locally which is why I ignored it. I personally think the intent is clear in that setting the position to -1 with the char ' ' is good enough but thank you for confirming.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$RawUI.SetBufferContents(
@{Top = -1; Bottom = -1; Right = -1; Left = -1},
@{Character = ' '; ForegroundColor = $rawui.ForegroundColor; BackgroundColor = $rawui.BackgroundColor})
To catch only such a method call, you need to check the colors too. Otherwise, someone may try to paint over the screen in a different color, and get the screen cleaned, which would mislead users because other parameter values would cause the exception.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
CL-General
Indicates that a PR should be marked as a general cmdlet change in the Change Log
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|