Update detection without trycatch

This commit is contained in:
Jens Du Four
2024-04-02 11:49:03 +02:00
parent c20d6847a4
commit 464dca7635

View File

@@ -1,17 +1,8 @@
try {
if (-not (Test-Path -LiteralPath "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location")) {
return $false
exit 1
}
if ((Get-ItemPropertyValue -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location' -Name 'Value' -ea SilentlyContinue) -eq 'Allow') {
return $true
if (Test-Path -LiteralPath "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location") {
$value = Get-ItemPropertyValue -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location' -Name 'Value' -ErrorAction SilentlyContinue
if ($value -eq 'Allow') {
exit 0
} else {
return $false
exit 1
}
}
catch {
return $false
exit 1
}
}
exit 1