Files
winutil/functions/private/Get-WinUtilRegistryComboState.ps1
T
OmarandGitHub bc607b6c91 Make MPO tweak a three-state control (#4897)
* refactor: make MPO tweak a three-state control

* docs: explain MPO tweak states

* docs: address code review comments

* refactor: make Multiplane Overlay config-driven
2026-08-09 14:02:42 -05:00

37 lines
1.3 KiB
PowerShell

function Get-WinUtilRegistryComboState {
<#
.SYNOPSIS
Finds the configured combo-box state matching the current registry values.
.PARAMETER Registry
Registry settings containing a value mapping for each supported state.
.OUTPUTS
The name of the matching state.
#>
param(
[Parameter(Mandatory)]
$Registry
)
foreach ($state in $Registry[0].Values.PSObject.Properties) {
$stateMatches = $true
foreach ($setting in @($Registry)) {
$currentValue = Get-WinUtilRegistryComboValue -Setting $setting
$actualValue = if ($currentValue.Exists -and $null -ne $currentValue.Value) { $currentValue.Value } else { $setting.DefaultValue }
$configuredValue = $setting.Values.PSObject.Properties[$state.Name].Value
# Removal represents the effective Windows default when matching the current state.
$expectedValue = if ($configuredValue -eq "<RemoveEntry>") { $setting.DefaultValue } else { $configuredValue }
if ([string]$actualValue -ne [string]$expectedValue) {
$stateMatches = $false
break
}
}
if ($stateMatches) {
return $state.Name
}
}
throw "Registry values do not match a supported state."
}