Files
winutil/functions/private/Get-WinUtilToggleStatus.ps1
T
Chris Titus 5aa099f6e2 Fix missing dism metadata (#4516)
* Fix product key invalid and missing metadata on some isos

* Fix Gabi's broken light mode pr
2026-05-19 14:11:27 -05:00

48 lines
1.2 KiB
PowerShell

Function Get-WinUtilToggleStatus {
param(
[string]$ToggleSwitch
)
$toggleSwitchReg = if ($ToggleSwitch) {
$sync.configs.tweaks.$ToggleSwitch.registry
} else {
$ToggleSwitchReg
}
if (-not $toggleSwitchReg) {
return $false
}
New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS
foreach ($regentry in $toggleSwitchReg) {
if (-not (Test-Path $regentry.Path)) {
New-Item -Path $regentry.Path -Force | Out-Null
}
$regstate = (Get-ItemProperty -Path $regentry.Path).$($regentry.Name)
if ($null -eq $regstate) {
switch ($regentry.DefaultState) {
"true" {
$regstate = $regentry.Value
}
"false" {
$regstate = $regentry.OriginalValue
}
default {
Write-Error "Entry $($regentry.Name): missing value and no DefaultState"
$regstate = $regentry.OriginalValue
}
}
}
if ($regstate -ne $regentry.Value) {
return $false
}
}
return $true
}