Skip to content

Guard MSI UpgradeCode lookup against missing registry key#2

Merged
Tom Plant (pl4nty) merged 1 commit into
fix/getadtapp-upgradecodes-missingfrom
claude/registry-path-not-found-c51i5e
Jul 4, 2026
Merged

Guard MSI UpgradeCode lookup against missing registry key#2
Tom Plant (pl4nty) merged 1 commit into
fix/getadtapp-upgradecodes-missingfrom
claude/registry-path-not-found-c51i5e

Conversation

@pl4nty

Copy link
Copy Markdown
Member

Get-ADTApplication built its MSI UpgradeCode lookup table with an unguarded Get-ChildItem on
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes. On machines where that key does not exist (e.g. images with no MSI-registered upgrade codes), Get-ChildItem threw a PathNotFound error that aborted the function's begin block, breaking any caller such as Uninstall-ADTApplication.

Add -ErrorAction Ignore to match the pattern already used for the uninstall key enumeration. When the key is absent the pipeline yields no items, the scriptblock's begin/end blocks still run, and the lookup table is simply empty; downstream indexing already returns $null for GUIDs that are not present.

Claude-Session: https://claude.ai/code/session_01XLNM98Nd3HZLTWFatRVgB1

Pull Request

Description

Please include a summary of any changes. Please also include relevant motivation and context.

Fixes: #12345

Fixes: https://github.com/PSAppDeployToolkit/PSAppDeployToolkit/issues/12345

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • General code cleanup (non-breaking change which improves readability)

Checklist

  • I am pulling to the main branch
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have tested my changes to prove my fix is effective
  • I have tested that the module can build following my changes
  • I have made sure that any script file-encoding is set to UTF8 with BOM, i.e. unchanged.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Get-ADTApplication built its MSI UpgradeCode lookup table with an
unguarded Get-ChildItem on
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes.
On machines where that key does not exist (e.g. images with no
MSI-registered upgrade codes), Get-ChildItem threw a PathNotFound
error that aborted the function's begin block, breaking any caller
such as Uninstall-ADTApplication.

Add -ErrorAction Ignore to match the pattern already used for the
uninstall key enumeration. When the key is absent the pipeline yields
no items, the scriptblock's begin/end blocks still run, and the
lookup table is simply empty; downstream indexing already returns
$null for GUIDs that are not present.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XLNM98Nd3HZLTWFatRVgB1
@pl4nty Tom Plant (pl4nty) merged commit e657a79 into fix/getadtapp-upgradecodes-missing Jul 4, 2026
3 checks passed
@pl4nty Tom Plant (pl4nty) deleted the claude/registry-path-not-found-c51i5e branch July 4, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants