fixed registry query logic

This commit is contained in:
Brian Warren 2025-04-06 01:29:11 -05:00
parent 6a0cdaf509
commit 050e08f497

View File

@ -383,258 +383,6 @@ function Get-TypeLibKeys {
) )
} }
# $template = New-Object System.Collections.Generic.List[System.Object];
# # CLSID keys
# $template.AddRange(
# @(
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\CLSID\{$clsid}"
# Values = @(
# @{
# Name = '(default)'
# Value = $classLabel
# },
# @{
# Name = 'AppID'
# Value = "{$appId}"
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\CLSID\{$clsid}\LocalServer32"
# Values = @(
# @{
# Name = '(default)'
# Value = $comServerPath
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\CLSID\{$clsid}\ProgID"
# Values = @(
# @{
# Name = '(default)'
# Value = $progId
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\CLSID\{$clsid}\Programmable"
# Values = @()
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\CLSID\{$clsid}\TypeLib"
# Values = @(
# @{
# Name = '(default)'
# Value = $typeLibId
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\CLSID\{$clsid}\VersionIndependentProgID"
# Values = @()
# }
# )
# );
# # Interface keys
# $template.AddRange(
# @(
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$interfaceId}"
# Values = @(
# @{
# Name = '(default)'
# Value = $interfaceName
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$interfaceId}\ProxyStubClsid"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$proxyStubClsid}"
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$interfaceId}\ProxyStubClsid32"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$proxyStubClsid}"
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$interfaceId}\TypeLib"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$typeLibId}"
# },
# @{
# Name = 'Version'
# Value = $typeLibVersion }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$eventInterfaceId}"
# Values = @(
# @{
# Name = '(default)'
# Value = $eventInterfaceName
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$eventInterfaceId}\ProxyStubClsid"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$proxyStubClsid}"
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$eventInterfaceId}\ProxyStubClsid32"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$proxyStubClsid32}"
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\Interface\{$eventInterfaceId}\TypeLib"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$typeLibId}"
# }
# @{
# Name = 'Version'
# Value = $typeLibVersion
# }
# )
# }
# )
# )
# # Prog ID keys
# $template.AddRange(
# @(
# @{
# Key = "$($registryHive):\SOFTWARE\Classes\$progId"
# Values = @(
# @{
# Name = '(default)'
# Value = $classLabel
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes\$progId\CLSID"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$clsid}"
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes\$progId\CurVer"
# Values = @(
# @{
# Name = '(default)'
# Value = $versionIndependentProgId
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes\$versionIndependentProgId"
# Values = @(
# @{
# Name = '(default)'
# Value = $classLabel
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes\$versionIndependentProgId\CLSID"
# Values = @(
# @{
# Name = '(default)'
# Value = "{$clsid}"
# }
# )
# }
# )
# )
# # TypeLib keys (add to both standard and Wow6432Node if architecture is x64)
# if ($architectureNode -eq '\') {
# $typeLibIterations = 1
# } else {
# $typeLibIterations = 2
# }
# for ($i = 0; $i -lt $typeLibIterations; $i++) {
# if ($i -eq 1) {
# $architectureNode = '\'
# }
# $template.AddRange(
# @(
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\TypeLib\{$typeLibId}"
# Values = @()
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\TypeLib\{$typeLibId}\$typeLibVersion"
# Values = @(
# @{
# Name = '(default)'
# Value = $typeLibLabel
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\TypeLib\{$typeLibId}\$typeLibVersion\0"
# Values = @()
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\TypeLib\{$typeLibId}\$typeLibVersion\0\win32"
# Values = @(
# @{
# Name = '(default)'
# Value = $comServerNetworkPath
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\TypeLib\{$typeLibId}\$typeLibVersion\FLAGS"
# Values = @(
# @{
# Name = '(default)'
# Value = '0'
# }
# )
# },
# @{
# Key = "$($registryHive):\SOFTWARE\Classes$($architectureNode)\TypeLib\{$typeLibId}\$typeLibVersion\HELPDIR"
# Values = @(
# @{
# Name = '(default)'
# Value = "$comServerDir\"
# }
# )
# }
# )
# )
# }
function Get-Keys { function Get-Keys {
param( param(
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
@ -698,7 +446,7 @@ switch ($action) {
#Write-Host "Created registry value: $($value.Name) in $($key.Key)" #Write-Host "Created registry value: $($value.Name) in $($key.Key)"
} }
catch { catch {
Write-Error "Failed to create registry value: $($value.Name) in $($key.Key)" Write-Error "Failed to create entry: $($value.Name) in $($key.Key)"
continue continue
} }
} }
@ -707,26 +455,16 @@ switch ($action) {
default { default {
$keys = Get-Keys -bothArchitectures $keys = Get-Keys -bothArchitectures
foreach ($key in $keys) { foreach ($key in $keys) {
Write-Debug "[$($key.Key)]"
foreach ($valuePair in $key.Values) {
try { try {
Write-Debug "Querying key: $($key.Key)" $value = Get-ItemPropertyValue -Path $key.Key -Name $valuePair.Name -ErrorAction Stop
# $key = Get-Item -Path $keyEl.Key -ErrorAction Stop
$foundKey = Get-Item -Path $key.Key -ErrorAction Stop
Write-Host "[$($foundKey.Key)]"
} }
catch { catch {
Write-Debug "Failed to find registry key: $($key.Key)" Write-Debug "Failed to find value for $($valuePair.Name)"
continue
}
foreach ($value in $foundKey.Values) {
try {
# $foundValue = Get-ItemPropertyValue -Path $key.Key -Name $value.Name -ErrorAction Stop
#$foundValue = Get-ItemPropertyValue -Path $key.Key -Name $value.Name -ErrorAction Stop
Write-Host "$($foundValue.Name)=$($foundValue.Value)"
}
catch {
Write-Debug "Failed to find registry value: $($valueEl.Name) in $($key.Key)"
continue continue
} }
Write-Host "$($valuePair.Name)=$($value)"
} }
} }
} }