Skip to content

Commit

Permalink
(chocolateyGH-815) Changes 1,2,3
Browse files Browse the repository at this point in the history
1. (logic) Remove limit on bad keys, but
2. (reporting) ^^^ add warning about possibly corrupted registry if >10 are found.
3. (reporting) write-debug with number of keys matched
  • Loading branch information
dtgm committed Jun 19, 2016
1 parent 299e0dc commit 22bf42a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ param(
[array]$keys = Get-ChildItem -Path @($machine_key6432, $machine_key, $local_key) `
-ErrorAction SilentlyContinue

Write-Debug "Error handling check: Get-ItemProperty will fail if a registry key is written incorrectly."
Write-Debug "If such a key is found, loop up to 10 times to try to bypass all badKeys"
[int]$maxAttempts = 10
Write-Debug "Error handling check: Get-ItemProperty will fail if a registry key is encoded incorrectly."
[int]$maxAttempts = $keys.Count
for ([int]$attempt = 1; $attempt -le $maxAttempts; $attempt++) {
[bool]$success = $FALSE

Expand All @@ -127,6 +126,9 @@ param(
if ($success) { break; }
}

if ($($foundkey.Count) -eq $null) {
Write-Verbose "No registry key found with SoftwareName:`'$softwareName`'";
}
return $foundKey
}

Expand Down

0 comments on commit 22bf42a

Please sign in to comment.