mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-04 22:27:28 +00:00
a09736f9a8
* Cleanup Get-WinUtilToggleStatus.ps1 * Update Get-WinUtilToggleStatus.ps1 * Merge branch 'main' into patch-9 * Update Get-WinUtilToggleStatus.ps1
38 lines
1003 B
PowerShell
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
|
|
}
|