Skip to content

[release/v7.5.12] Add GetImportModuleCommand method and session restriction check in ShowCommand - #28073

Merged
Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:release/v7.5.12from
adityapatwardhan:backport/release/v7.5.12/25557-eef085210
Sep 23, 2026
Merged

Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:release/v7.5.12from
adityapatwardhan:backport/release/v7.5.12/25557-eef085210

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

Backport of #25557 to release/v7.5.12

Triggered by Aditya Patwardhan (@adityapatwardhan) on behalf of Travis Plunk (@TravisEz13)

Original CL Label: CL-General

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

Fixes #25556, where Show-Command lacks the module import helper behavior and can run in unsupported restricted remoting sessions instead of returning a clear terminating error.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

The Show-Command behavior regression was introduced by #20593.

Testing

The backport cherry-picked cleanly and passes git diff --check and HelpErrors.resx XML parsing. Builds of the two affected projects were attempted after restoring dependencies but were blocked in an unrelated dependency project by missing generated DotNetEventingStrings resources in Microsoft.PowerShell.CoreCLR.Eventing.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk because this changes Show-Command behavior and module-import script generation, but the changes are limited to the graphical host helper and an explicit restricted-session guard. The backport cherry-picked cleanly.

Copilot AI lite review requested due to automatic review settings September 23, 2026 18:53
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 23, 2026
@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

🟡 Changes recommended

The remote fallback is missing a statement separator, producing invalid PowerShell syntax.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Backports Show-Command module-import support and restricted-session validation to v7.5.12.

Changes:

  • Adds module-import command generation.
  • Rejects unsupported restricted sessions.
  • Adds the localized error resource.
File Description
src/​System.Management.Automation/​resources/​HelpErrors.resx Adds the restricted-session error message.
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​ShowCommand/​ShowCommand.cs Adds restricted-session validation.
src/​Microsoft.Management.UI.Internal/​commandHelpers/​ShowCommandHelper.cs Generates module-import and refresh commands.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

}
else
{
scriptBase += GetSerializedCommandScript();
Comment on lines +493 to +494
/// Gets the command to be run to in order to import a module and refresh the command data.
/// </summary>
/// </summary>
/// <param name="module">Module we want to import.</param>
/// <param name="isRemoteRunspace">Boolean flag determining whether Show-Command is queried in the local or remote runspace scenario.</param>
/// <param name="isFirstChance">Boolean flag to indicate that it is the second attempt to query Show-Command data.</param>
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit a78ac39 into PowerShell:release/v7.5.12 Sep 23, 2026
36 checks passed
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) deleted the backport/release/v7.5.12/25557-eef085210 branch September 23, 2026 21:21
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.

5 participants