Files
winutil/functions/private/Get-WinUtilSelectedPackages.ps1
Paweł Gwozdowski 0028e439b5 Cleaned up typos, fixes grammatical errors and other related fixes (#4215)
* cleaned up typo, fixes, grammatical and other related fixes (#2)

* typo in Lightshot app name

* remove trailing comma in applications.json

* consistent capitalization of Windows, WinGet - only user-facing text

	- includes update to devdocs-generator.ps1, so docs for tweaks modifying registry will have `Windows settings` rather than `windows settings`

* various fixes for typos, style, punctuation and capitalization

* capitalize 'AM'

* Update README.md

change formatting for GitHub UI interaction form code format (` `) to bold md

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* typos and wording in docs

---------

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
2026-03-26 15:26:21 -05:00

60 lines
2.1 KiB
PowerShell

function Get-WinUtilSelectedPackages
{
<#
.SYNOPSIS
Sorts given packages based on installer preference and availability.
.OUTPUTS
Hashtable. Key = Package Manager, Value = ArrayList of packages to install
#>
param (
[Parameter(Mandatory=$true)]
$PackageList,
[Parameter(Mandatory=$true)]
[PackageManagers]$Preference
)
if ($PackageList.count -eq 1) {
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" }
} else {
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" }
}
$packages = [System.Collections.Hashtable]::new()
$packagesWinget = [System.Collections.ArrayList]::new()
$packagesChoco = [System.Collections.ArrayList]::new()
$packages[[PackageManagers]::Winget] = $packagesWinget
$packages[[PackageManagers]::Choco] = $packagesChoco
Write-Debug "Checking packages using Preference '$($Preference)'"
foreach ($package in $PackageList) {
switch ($Preference) {
"Choco" {
if ($package.choco -eq "na") {
Write-Debug "$($package.content) has no Choco value."
$null = $packagesWinget.add($($package.winget))
Write-Host "Queueing $($package.winget) for WinGet..."
} else {
$null = $packagesChoco.add($package.choco)
Write-Host "Queueing $($package.choco) for Chocolatey..."
}
break
}
"Winget" {
if ($package.winget -eq "na") {
Write-Debug "$($package.content) has no WinGet value."
$null = $packagesChoco.add($package.choco)
Write-Host "Queueing $($package.choco) for Chocolatey..."
} else {
$null = $packagesWinget.add($($package.winget))
Write-Host "Queueing $($package.winget) for WinGet..."
}
break
}
}
}
return $packages
}