mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-05 14:18:31 +00:00
* 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>
60 lines
2.1 KiB
PowerShell
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
|
|
}
|