From 464dca763502855d808c37b17f7b7db37bc26d87 Mon Sep 17 00:00:00 2001 From: Jens Du Four Date: Tue, 2 Apr 2024 11:49:03 +0200 Subject: [PATCH] Update detection without trycatch --- Intune_Remediation_Timezone/detection.ps1 | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Intune_Remediation_Timezone/detection.ps1 b/Intune_Remediation_Timezone/detection.ps1 index d8a347d..0f9a2b0 100644 --- a/Intune_Remediation_Timezone/detection.ps1 +++ b/Intune_Remediation_Timezone/detection.ps1 @@ -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 -} \ No newline at end of file +} + +exit 1 \ No newline at end of file