GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing github.com — Add GetImportModuleCommand method and session restriction check in ShowCommand by TravisEz13 · Pull Request #25557 · PowerShell/PowerShell Conversation
|
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This PR addresses #25556 by restoring a missing helper used by Show-Command to import modules and refresh command metadata (used by the UI when showing command details), and by preventing Show-Command from running in restricted sessions where it isn’t supported.
Changes:
GetImportModuleCommand script generation logic in ShowCommandHelper to support module import + command refresh (including remote-runspace scenarios).ShowCommand BeginProcessing to terminate early with a clear error.| File | Description |
|---|---|
| src/System.Management.Automation/resources/HelpErrors.resx | Adds a new error string used when blocking execution in restricted sessions. |
| src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommand.cs | Blocks Show-Command in restricted sessions via Utils.IsSessionRestricted(...) and throws a terminating error. |
| src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs | Restores GetImportModuleCommand to generate import/refresh scripts for Show-Command module loading flows. |
src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs:511
Import-Module ... without a statement separator, producing an invalid PowerShell script (e.g., Import-Module 'X'@( ... )). Add a ; before the serialized script so it runs as a separate statement. scriptBase += GetSerializedCommandScript();
src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs:498
isFirstChance is documented as indicating the second attempt, but the name (and default value) indicate the first attempt. This mismatch can easily lead to incorrect future call sites or changes. /// <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>
/// <returns>The command to be run to in order to import a module and refresh the command data.</returns>
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
eef0852
into
PowerShell:master
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Show-Command crashes when clicking "Show Details" on a command
There was an error while loading. Please reload this page.