GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix Clear-Host for remote Windows PSSession by jborean93 · Pull Request #28116 · PowerShell/PowerShell

Conversation

@jborean93

@jborean93 Jordan Borean (jborean93) commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

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

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

0xfeeddeadbeef reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@jborean93
Fix Clear-Host for remote Windows PSSession
70ef4fe
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`.
Copilot AI lite review requested due to automatic review settings September 28, 2026 11:05
@jborean93
Jordan Borean (jborean93) requested a review from a team as a code owner September 28, 2026 11:05
@azure-pipelines

azure-pipelines Bot commented Sep 28, 2026

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Jordan Borean (jborean93) September 28, 2026 11:05
View session
Copilot AI reviewed Sep 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
@jborean93 Jordan Borean (jborean93) mentioned this pull request Sep 28, 2026
Enter-PSSession - Clear-Host from non-Windows client to Windows target fails #28115
Closed
5 tasks done
iSazonov
Ilya (iSazonov) reviewed Sep 28, 2026
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs Outdated
fill.Character == ' ')
{
// Emits the same sequence as the clear command used by the
// local Clear-Host function.

@iSazonov Ilya (iSazonov) Sep 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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.

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Sep 28, 2026

Copy link
Copy Markdown
Member

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.

All reactions

@jborean93 Jordan Borean (jborean93) Sep 28, 2026

Copy link
Copy Markdown
Collaborator Author

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.

All reactions

@iSazonov Ilya (iSazonov) Sep 29, 2026

Copy link
Copy Markdown
Collaborator

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.

All reactions
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 28, 2026
daxian-dbw
Dongbo Wang (daxian-dbw) reviewed Sep 28, 2026
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jborean93 @daxian-dbw
Update src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUs…
15672d4
…erInterface.cs

Co-authored-by: Dongbo Wang <[email protected]>
@jborean93 Jordan Borean (jborean93) mentioned this pull request Sep 29, 2026
Enter-PSSession - Clear-Host on non-Windows target fails #28118
Closed
5 tasks done
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Oct 6, 2026
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Oct 23, 2026
View reviewed changes
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit ac15e9a into PowerShell:master Oct 23, 2026
37 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw Dongbo Wang (daxian-dbw) removed the Review - Needed The PR is being reviewed label Oct 23, 2026
@jborean93
Jordan Borean (jborean93) deleted the clear-pssession-win branch October 23, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Enter-PSSession - Clear-Host from non-Windows client to Windows target fails

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@jborean93 @daxian-dbw @iSazonov
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.