2026-05-26 13:05:25 -07:00
|
|
|
Function Get-WinUtilToggleStatus ($ToggleSwitch) {
|
2026-05-19 14:11:27 -05:00
|
|
|
|
2026-05-26 13:05:25 -07:00
|
|
|
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry
|
2023-07-27 16:06:41 -05:00
|
|
|
|
2026-07-01 23:34:59 -05:00
|
|
|
if ($null -eq $sync.ToggleStatusCache) {
|
|
|
|
|
$sync.ToggleStatusCache = @{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($sync.ToggleStatusCache.ContainsKey($ToggleSwitch)) {
|
|
|
|
|
return [bool]$sync.ToggleStatusCache[$ToggleSwitch]
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-26 13:05:25 -07:00
|
|
|
if (-not (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
|
|
|
|
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
|
|
|
|
|
}
|
2023-11-14 15:45:48 -06:00
|
|
|
|
2026-05-26 13:05:25 -07:00
|
|
|
foreach ($regentry in $ToggleSwitchReg) {
|
2024-12-06 04:24:36 +01:00
|
|
|
|
2026-07-01 23:34:59 -05:00
|
|
|
if (Test-Path $regentry.Path) {
|
|
|
|
|
$regstate = (Get-ItemProperty -Path $regentry.Path).$($regentry.Name)
|
|
|
|
|
} else {
|
|
|
|
|
$regstate = $null
|
2024-12-06 04:24:36 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-19 21:13:27 +03:00
|
|
|
if ($null -eq $regstate) {
|
2026-07-01 23:34:59 -05:00
|
|
|
switch ([string]$regentry.DefaultState) {
|
2026-05-26 13:05:25 -07:00
|
|
|
"true" { $regstate = $regentry.Value }
|
|
|
|
|
"false" { $regstate = $regentry.OriginalValue }
|
2024-12-06 04:24:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 21:13:27 +03:00
|
|
|
if ($regstate -ne $regentry.Value) {
|
2026-07-01 23:34:59 -05:00
|
|
|
$sync.ToggleStatusCache[$ToggleSwitch] = $false
|
2024-12-06 04:24:36 +01:00
|
|
|
return $false
|
|
|
|
|
}
|
2024-07-31 03:50:50 +02:00
|
|
|
}
|
2026-05-19 21:13:27 +03:00
|
|
|
|
2026-07-01 23:34:59 -05:00
|
|
|
$sync.ToggleStatusCache[$ToggleSwitch] = $true
|
2026-05-19 21:13:27 +03:00
|
|
|
return $true
|
2024-04-20 16:38:43 -05:00
|
|
|
}
|