Skip to content

fix(agent): find Store pwsh and fix PowerShell arguments - #2175

Merged
Benoît Cortier (CBenoit) merged 3 commits into
masterfrom
claude/devolutions-agent-pwsh-detection-7f0565
Oct 28, 2026
Merged

Benoît Cortier (CBenoit) merged 3 commits into
masterfrom
claude/devolutions-agent-pwsh-detection-7f0565

Conversation

@mamoreau-devolutions

@mamoreau-devolutions Marc-André Moreau (mamoreau-devolutions) commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The package broker only reported PowerShell 7 as available when the MSI installation existed under Program Files, so machines with the Microsoft Store installation could not broker PowerShell 7 operations. The broker now falls back to the user's pwsh.exe app execution alias, validated against the Microsoft.PowerShell package family like the winget.exe alias, and launches the WindowsApps target it pinned during that validation.

Several generated PowerShell commands passed parameters the cmdlets do not accept, so those operations always failed: -Repository on Uninstall-PSResource, Uninstall-Module and Update-Module, and -SkipPublisherCheck on Update-Module. Those commands act on installed modules, and Update-Module updates from the repository a module was installed from, so they now first check that every installed version, prereleases included, came from the policy-matched source and fail otherwise.

🤖 Generated with Claude Code

The package broker only reported PowerShell 7 as available when the MSI
installation existed under Program Files, so machines with the
Microsoft Store installation could not broker PowerShell 7 operations.
The broker now falls back to the user's pwsh.exe app execution alias,
validated against the Microsoft.PowerShell package family like the
winget.exe alias, and launches the verified WindowsApps target.

Several generated PowerShell commands passed parameters the cmdlets do
not accept, so those operations always failed: -Repository on
Uninstall-PSResource, Uninstall-Module and Update-Module, and
-SkipPublisherCheck on Update-Module. Update-Module updates from the
repository a module was installed from, so the Windows PowerShell
update first checks that this repository is the policy-matched source
and fails otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 13:45
@mamoreau-devolutions

Marc-André Moreau (mamoreau-devolutions) commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Lines changed:

Area Added Removed
Production code 158 18
Tests 194 14
Other files 0 0

Validation:

  • Checked the cmdlet parameters against PSResourceGet 1.2.0 and PowerShellGet 2.2.5 / 1.0.0.1.
  • Ran the generated installed-repository checks in real hosts (Windows PowerShell with PowerShellGet 2.2.5 and 1.0.0.1, and pwsh 7.6.9): a matching repository proceeds, a different repository and a missing module both exit with code 1.
  • The opportunistic pwsh_app_exec_alias_resolves_to_windowsapps_target test resolved and pinned a real Store pwsh.exe alias locally.
  • Known gap: the inbox PowerShellGet 1.0.0.1 has no -Scope or -AllowPrerelease on Update-Module, so Windows PowerShell updates still require PowerShellGet 2.x.

@github-actions

Copy link
Copy Markdown

Let maintainers know that an action is required on their side

  • Add the label release-required Please cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module) when you request a maintainer to cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module)

  • Add the label release-blocker Follow-up is required before cutting a new release if a follow-up is required before cutting a new release

  • Add the label publish-required Please publish libraries (`Devolutions.Gateway.Utils`, OpenAPI clients, etc) when you request a maintainer to publish libraries (Devolutions.Gateway.Utils, OpenAPI clients, etc.)

  • Add the label publish-blocker Follow-up is required before publishing libraries if a follow-up is required before publishing libraries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

🟡 Changes recommended

The review found an issue that should be addressed before approval.

3 open issues
What changed in this PR

This PR adds Microsoft Store PowerShell 7 discovery to the package broker and corrects unsupported PowerShell cmdlet arguments.

Changes:

  • Fall back to the target user’s pwsh.exe alias when the MSI installation is absent.
  • Extend alias validation to the Microsoft PowerShell package family.
  • Remove unsupported parameters and check the installed repository before Windows PowerShell updates.
File Description
crates/​now-package-broker/​src/​policy_security.rs Adds PowerShell alias identity validation and tests.
crates/​now-package-broker/​src/​executor/​windows/​mod.rs Adds Store PowerShell discovery for availability checks and command preparation.
crates/​now-package-broker/​src/​command_builder/​powershell.rs Corrects cmdlet arguments and adds update repository checks and regression tests.

Review effort: Balanced

Check the installed repository before Uninstall-Module and
Uninstall-PSResource, which take no -Repository, and list prerelease
versions in the Windows PowerShell check. Launch the Store pwsh from
the alias target pinned when the alias was validated, so replacing the
alias afterwards cannot redirect the launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CBenoit
Benoît Cortier (CBenoit) merged commit e382917 into master Oct 28, 2026
53 checks passed
@CBenoit
Benoît Cortier (CBenoit) deleted the claude/devolutions-agent-pwsh-detection-7f0565 branch October 28, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants