winutil/functions/private/Get-WinUtilCheckBoxes.ps1
MyDrift a8df0d3ede Block Adobe Network, Debloat Adobe & Compile
- fixes order of tweaks to always run "WPFTweaksRestorePoint" first. Before it was only the case because if was one of the first letter0s of the alphabet
- Fixed some stuff at Debloat Adobe & added Adobe Reader update stopper & "deactivated" Adobe Desktop Service.
- Added Blocking of Adobe Servers (as of your suggestion) to it's own Tweak.
- ran compile for testing & showing
2024-05-09 20:30:12 +02:00

86 lines
2.7 KiB
PowerShell

Function Get-WinUtilCheckBoxes {
<#
.SYNOPSIS
Finds all checkboxes that are checked on the specific tab and inputs them into a script.
.PARAMETER unCheck
Whether to uncheck the checkboxes that are checked. Defaults to true
.OUTPUTS
A List containing the name of each checked checkbox
.EXAMPLE
Get-WinUtilCheckBoxes "WPFInstall"
#>
Param(
[boolean]$unCheck = $false
)
$Output = @{
Install = @()
WPFTweaks = @()
WPFFeature = @()
WPFInstall = @()
}
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $_.Value -is [System.Windows.Controls.CheckBox] }
# First check and add WPFTweaksRestorePoint if checked
$RestorePoint = $CheckBoxes | Where-Object { $_.Key -eq 'WPFTweaksRestorePoint' -and $_.Value.IsChecked -eq $true }
if ($RestorePoint) {
$Output["WPFTweaks"] = @('WPFTweaksRestorePoint')
Write-Debug "Adding WPFTweaksRestorePoint as first in WPFTweaks"
if ($unCheck) {
$RestorePoint.Value.IsChecked = $false
}
}
foreach ($CheckBox in $CheckBoxes) {
if ($CheckBox.Key -eq 'WPFTweaksRestorePoint') { continue } # Skip since it's already handled
$group = if ($CheckBox.Key.StartsWith("WPFInstall")) { "Install" }
elseif ($CheckBox.Key.StartsWith("WPFTweaks")) { "WPFTweaks" }
elseif ($CheckBox.Key.StartsWith("WPFFeature")) { "WPFFeature" }
if ($group) {
if ($CheckBox.Value.IsChecked -eq $true) {
$feature = switch ($group) {
"Install" {
$wingetValue = $sync.configs.applications.$($CheckBox.Name).winget
if (-not [string]::IsNullOrWhiteSpace($wingetValue) -and $wingetValue -ne "na") {
$wingetValue -split ";"
} else {
$sync.configs.applications.$($CheckBox.Name).choco
}
}
default {
$CheckBox.Name
}
}
if (-not $Output.ContainsKey($group)) {
$Output[$group] = @()
}
if ($group -eq "Install") {
$Output["WPFInstall"] += $CheckBox.Name
Write-Debug "Adding: $($CheckBox.Name) under: WPFInstall"
}
Write-Debug "Adding: $($feature) under: $($group)"
$Output[$group] += $feature
if ($unCheck) {
$CheckBox.Value.IsChecked = $false
}
}
}
}
return $Output
}