From 204b7d30aa342455e4d12858ca9d237cefffeb23 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 4 Jul 2026 03:12:25 +0000 Subject: [PATCH] Guard MSI UpgradeCode lookup against missing registry key 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 Claude-Session: https://claude.ai/code/session_01XLNM98Nd3HZLTWFatRVgB1 --- src/PSAppDeployToolkit/Public/Get-ADTApplication.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PSAppDeployToolkit/Public/Get-ADTApplication.ps1 b/src/PSAppDeployToolkit/Public/Get-ADTApplication.ps1 index 34df6bfadf5..393d68c6868 100644 --- a/src/PSAppDeployToolkit/Public/Get-ADTApplication.ps1 +++ b/src/PSAppDeployToolkit/Public/Get-ADTApplication.ps1 @@ -178,7 +178,7 @@ function Get-ADTApplication # Define compiled regex for use throughout main loop. $updatesAndHotFixesRegex = [System.Text.RegularExpressions.Regex]::new('((?i)kb\d+|(Cumulative|Security) Update|Hotfix)', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase -bor [System.Text.RegularExpressions.RegexOptions]::Compiled) - $msiUpgradeCodeLookupTable = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\* | Get-ItemProperty | & { + $msiUpgradeCodeLookupTable = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\* -ErrorAction Ignore | Get-ItemProperty | & { begin { # Open lookup table dictionary for returning at the end.