fix error when key doesnt exist

This commit is contained in:
zoicware
2025-11-17 13:05:35 -06:00
committed by GitHub
parent aedc9bf7ca
commit 4eeea16fb0

View File

@@ -1472,7 +1472,7 @@ function Hide-AI-Components {
Reg.exe delete 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' /v 'SettingsPageVisibility' /f >$null
}
else {
$existingSettings = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' -Name 'SettingsPageVisibility' -ErrorAction SilentlyContinue
$existingSettings = try { Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' -Name 'SettingsPageVisibility' -ErrorAction SilentlyContinue }catch {}
if ($existingSettings) {
$newval = $existingSettings + 'aicomponents;'
Reg.exe add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' /v 'SettingsPageVisibility' /t REG_SZ /d $newval /f >$null