winutil/functions/private/Get-WinUtilCheckBoxes.ps1

76 lines
2.2 KiB
PowerShell

Function Get-WinUtilCheckBoxes {
<#
.SYNOPSIS
Finds all checkboxes that are checked on the specific tab and inputs them into a script.
.PARAMETER Group
The group of checkboxes to check
.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(
$Group,
[boolean]$unCheck = $true
)
$Output = New-Object System.Collections.Generic.List[System.Object]
if($Group -eq "WPFInstall"){
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"}
$CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter}
Foreach ($CheckBox in $CheckBoxes){
if($CheckBox.value.ischecked -eq $true){
$sync.configs.applications.$($CheckBox.Name).winget -split ";" | ForEach-Object {
$Output.Add($psitem)
}
if ($uncheck -eq $true){
$CheckBox.value.ischecked = $false
}
}
}
}
if($Group -eq "WPFTweaks"){
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPF*Tweaks*"}
$CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter}
Foreach ($CheckBox in $CheckBoxes){
if($CheckBox.value.ischecked -eq $true){
$Output.Add($Checkbox.Name)
if ($uncheck -eq $true){
$CheckBox.value.ischecked = $false
}
}
}
}
if($Group -eq "WPFFeature"){
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPF*Feature*"}
$CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter}
Foreach ($CheckBox in $CheckBoxes){
if($CheckBox.value.ischecked -eq $true){
$Output.Add($Checkbox.Name)
if ($uncheck -eq $true){
$CheckBox.value.ischecked = $false
}
}
}
}
Write-Output $($Output | Select-Object -Unique)
}