Skip to content

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

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

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

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

Backport of #25557 to release/v7.4.21

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

Restores Show-Command module import/command refresh behavior and prevents Show-Command from running in unsupported restricted remoting sessions, where it now terminates with a clear error.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

The regression was introduced by PR #20593.

Testing

Verified that the cherry-picked commit is exactly one commit ahead of upstream/release/v7.4.21, reviewed the resulting three-file diff against the original PR diff, and ran git diff --check successfully. Direct project builds were attempted but could not complete because the local checkout lacks generated restore/resource prerequisites (project.assets.json and DotNetEventingStrings); supported CI validation is required.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk because this changes customer-facing Show-Command behavior and restricted-remoting error handling. The change is narrowly scoped to restoring the module-import helper, adding one session restriction guard, and adding its resource string; it cherry-picked without conflicts.

Copilot AI lite review requested due to automatic review settings September 22, 2026 18:26
@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 22, 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

Fix the remote refresh script separator issue; also correct the isFirstChance documentation.

Get a fresh assessment by requesting another Copilot review.

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

Open (2)
What changed in this PR

Backports Show-Command fixes to restore module refresh behavior and reject unsupported restricted sessions.

Changes:

  • Restores module import and command refresh scripting.
  • Adds a restricted-session guard.
  • Adds the corresponding error resource.
File Summary
src/​System.Management.Automation/​resources/​HelpErrors.resx Adds the restricted-session error message.
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​ShowCommand/​ShowCommand.cs Adds the restricted-session guard.
src/​Microsoft.Management.UI.Internal/​commandHelpers/​ShowCommandHelper.cs Restores module import scripting; has an unresolved moderate issue (3 votes) requiring a statement separator, plus a documentation nit (3 votes).

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

}
else
{
scriptBase += GetSerializedCommandScript();
/// </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) changed the title [release/v7.4.21] Add GetImportModuleCommand method and session restriction check in ShowCommand WIP: [release/v7.4.21] Add GetImportModuleCommand method and session restriction check in ShowCommand Sep 22, 2026
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) changed the title WIP: [release/v7.4.21] Add GetImportModuleCommand method and session restriction check in ShowCommand [release/v7.4.21] Add GetImportModuleCommand method and session restriction check in ShowCommand Sep 22, 2026
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit 37b5998 into PowerShell:release/v7.4.21 Sep 22, 2026
38 of 39 checks passed
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) deleted the backport/release/v7.4.21/25557-eef085210 branch September 22, 2026 20:20
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