Files
winutil/functions/private/Get-WinUtilToggleStatus.ps1
T
Gabi a09736f9a8 Cleanup Get-WinUtilToggleStatus.ps1 (#4497)
* Cleanup Get-WinUtilToggleStatus.ps1

* Update Get-WinUtilToggleStatus.ps1

* Merge branch 'main' into patch-9

* Update Get-WinUtilToggleStatus.ps1
2026-05-19 13:13:27 -05:00

38 lines
1003 B
PowerShell

Function Get-WinUtilToggleStatus {
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
}