Skip to content

Commit e657a79

Browse files
authored
Guard Get-ADTApplication against missing UpgradeCode registry key
In Windows Sandbox, and potentially other scenarios, `HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes` doesn't exist until an MSI is installed
1 parent dff8573 commit e657a79

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/PSAppDeployToolkit/Public/Get-ADTApplication.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function Get-ADTApplication
178178

179179
# Define compiled regex for use throughout main loop.
180180
$updatesAndHotFixesRegex = [System.Text.RegularExpressions.Regex]::new('((?i)kb\d+|(Cumulative|Security) Update|Hotfix)', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase -bor [System.Text.RegularExpressions.RegexOptions]::Compiled)
181-
$msiUpgradeCodeLookupTable = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\* | Get-ItemProperty | & {
181+
$msiUpgradeCodeLookupTable = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\* -ErrorAction Ignore | Get-ItemProperty | & {
182182
begin
183183
{
184184
# Open lookup table dictionary for returning at the end.

0 commit comments

Comments
 (0)