From 28bea518f02d46ddfb3b3c3d7b887963ce421551 Mon Sep 17 00:00:00 2001
From: DeveloperDurp <developerdurp@durp.info>
Date: Sat, 28 Dec 2024 15:38:40 -0600
Subject: [PATCH] Add exception catch for Unauthorized Access (#3114)

---
 functions/private/Set-WinUtilRegistry.ps1 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/functions/private/Set-WinUtilRegistry.ps1 b/functions/private/Set-WinUtilRegistry.ps1
index cc81e1c8..b926d5dc 100644
--- a/functions/private/Set-WinUtilRegistry.ps1
+++ b/functions/private/Set-WinUtilRegistry.ps1
@@ -47,6 +47,8 @@ function Set-WinUtilRegistry {
         Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
     } catch [System.Management.Automation.ItemNotFoundException] {
         Write-Warning $psitem.Exception.ErrorRecord
+    } catch [System.UnauthorizedAccessException]{
+       Write-Warning $psitem.Exception.Message
     } catch {
         Write-Warning "Unable to set $Name due to unhandled exception"
         Write-Warning $psitem.Exception.StackTrace