Files
winutil/functions/private/Get-WinUtilSelectedPackages.ps1
T
727ba52a4d Deleted Test-WinUtilPackageManager.ps1 + custom winget and choco installs + remove winget/choco enums and exeptions (#4606)
* Update Invoke-WPFGetInstalled.ps1

* Update Install-WinUtilWinget.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilWinget.ps1

* Delete functions/private/Test-WinUtilPackageManager.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilWinget.ps1

* Update Install-WinUtilChoco.ps1

* Update Invoke-WPFGetInstalled.ps1

* Update Invoke-WPFGetInstalled.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilWinget.ps1

* Update Install-WinUtilWinget.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilWinget.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilWinget.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilChoco.ps1

* Update Install-WinUtilWinget.ps1

* Fixed lastrun.json

* refactor: remove PackageManagers enum and unused custom exception classes

* Update Invoke-WPFUIElements.ps1

* Update Get-WinUtilSelectedPackages.ps1

* Update Set-Preferences.ps1

* Update main.ps1

* Complete package manager enum removal

Use string package-manager preferences throughout the remaining helpers and focused tests. Restore the existing Winget install flow and package-manager probe helper so PR 4606 keeps the current WinGet repair method.

* Fix string keyed package split

---------

Co-authored-by: Chris Titus <contact@christitus.com>
2026-07-02 12:50:57 -05:00

56 lines
1.6 KiB
PowerShell

function Get-WinUtilSelectedPackages {
param(
[Parameter(Mandatory = $true)]
[object] $PackageList,
[Parameter(Mandatory = $true)]
[string] $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" }
}
$packagesWinget = [System.Collections.ArrayList]::new()
$packagesChoco = [System.Collections.ArrayList]::new()
$packages = @{
Winget = $packagesWinget
Choco = $packagesChoco
}
function Add-PackageId {
param(
[System.Collections.ArrayList]$Target,
$PackageId
)
if ([string]::IsNullOrWhiteSpace([string]$PackageId) -or $PackageId -eq "na") {
return
}
if (-not $Target.Contains($PackageId)) {
$null = $Target.Add($PackageId)
}
}
foreach ($package in $PackageList) {
switch ($Preference) {
"Choco" {
if ([string]::IsNullOrWhiteSpace([string]$package.choco) -or $package.choco -eq "na") {
Add-PackageId -Target $packagesWinget -PackageId $package.winget
} else {
Add-PackageId -Target $packagesChoco -PackageId $package.choco
}
}
"Winget" {
Add-PackageId -Target $packagesWinget -PackageId $package.winget
}
}
}
return $packages
}