From d855b081192df3f9147dbb756e5618b5deaba63e Mon Sep 17 00:00:00 2001 From: Martin Wiethan <47688561+Marterich@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:51:18 +0200 Subject: [PATCH] Add logic to remove Registry Keys via Tweaks (#2837) --- functions/private/Set-WinUtilRegistry.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/private/Set-WinUtilRegistry.ps1 b/functions/private/Set-WinUtilRegistry.ps1 index e3f66e2e..397ce84c 100644 --- a/functions/private/Set-WinUtilRegistry.ps1 +++ b/functions/private/Set-WinUtilRegistry.ps1 @@ -36,7 +36,12 @@ function Set-WinUtilRegistry { } Write-Host "Set $Path\$Name to $Value" - Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null + if ($Value -ne ""){ + Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null + } + else{ + Remove-ItemProperty -Path $Path -Name $Name -Force -ErrorAction Stop | Out-Null + } } catch [System.Security.SecurityException] { Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" } catch [System.Management.Automation.ItemNotFoundException] {