This commit is contained in:
Chris Titus 2024-07-16 23:55:56 -05:00
commit b319c32ae6

View File

@ -8,7 +8,7 @@
Author : Chris Titus @christitustech
Runspace Author: @DeveloperDurp
GitHub : https://github.com/ChrisTitusTech
Version : 24.07.16
Version : 24.07.17
#>
param (
[switch]$Debug,
@ -45,7 +45,7 @@ Add-Type -AssemblyName System.Windows.Forms
# Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{})
$sync.PSScriptRoot = $PSScriptRoot
$sync.version = "24.07.16"
$sync.version = "24.07.17"
$sync.configs = @{}
$sync.ProcessRunning = $false
@ -1001,17 +1001,16 @@ Function Install-WinUtilProgramWinget {
[Parameter(Position=1)]
[String]$manage = "Installing"
)
$x = 0
$count = $ProgramsToInstall.Count
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---"
Write-Host "==========================================="
for ($i = 0; $i -le $ProgramsToInstall.Count; $i++) {
$Program = $ProgramsToInstall[$i]
Foreach ($Program in $ProgramsToInstall){
$failedPackages = @()
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($i + 1) of $count" -PercentComplete $(($i/$count) * 100)
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($x + 1) of $count" -PercentComplete $($x/$count*100)
if($manage -eq "Installing"){
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
@ -1061,7 +1060,7 @@ Function Install-WinUtilProgramWinget {
$failedPackages += $Program
}
}
elseif($manage -eq "Uninstalling") {
if($manage -eq "Uninstalling"){
# Uninstall package via ID using winget directly.
try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
@ -1076,9 +1075,7 @@ Function Install-WinUtilProgramWinget {
$failedPackages += $Program
}
}
else {
throw "[Install-WinUtilProgramWinget] Invalid Value for Parameter 'manage', Provided Value is: $manage"
}
$X++
}
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
return $failedPackages;