Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Fix Clear-Host for remote Windows PSSession - #28116

Merged
Dongbo Wang (daxian-dbw) merged 2 commits into
PowerShell:masterfrom
jborean93:clear-pssession-win
Oct 23, 2026
Merged

Dongbo Wang (daxian-dbw) merged 2 commits into
PowerShell:masterfrom
jborean93:clear-pssession-win

Conversation

@jborean93

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

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

fill.Character == ' ')
{
// Emits the same sequence as the clear command used by the
// local Clear-Host function.

@iSazonov Ilya (iSazonov) Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Collaborator Author

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.

Copy link
Copy Markdown
Collaborator

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.

@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
…erInterface.cs

Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
@microsoft-github-policy-service

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

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit ac15e9a into PowerShell:master Oct 23, 2026
37 checks passed
@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

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants