mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-29 09:32:35 -05:00
Edge Removal Fix
This commit is contained in:
@ -16,7 +16,7 @@ Function Invoke-WinUtilWingetProgram {
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory, Position=0)]$Programs,
|
||||
|
||||
|
||||
[Parameter(Mandatory, Position=1)]
|
||||
[ValidateSet("Install", "Uninstall")]
|
||||
[String]$Action
|
||||
@ -35,7 +35,7 @@ Function Invoke-WinUtilWingetProgram {
|
||||
|
||||
.PARAMETER credential
|
||||
The PSCredential Object of the user that should be used to run winget
|
||||
|
||||
|
||||
.NOTES
|
||||
Invoke Winget uses the public variable $Action defined outside the function to determine if a Program should be installed or removed
|
||||
#>
|
||||
@ -47,7 +47,7 @@ Function Invoke-WinUtilWingetProgram {
|
||||
|
||||
$commonArguments = "--id $wingetId --silent"
|
||||
$arguments = if ($Action -eq "Install") {
|
||||
"install $commonArguments --accept-source-agreements --accept-package-agreements $(if ($scope) {" --scope $scope"})"
|
||||
"install $commonArguments --accept-source-agreements --accept-package-agreements $(if ($scope) {" --scope $scope"})"
|
||||
} else {
|
||||
"uninstall $commonArguments"
|
||||
}
|
||||
@ -63,15 +63,15 @@ Function Invoke-WinUtilWingetProgram {
|
||||
if ($credential) {
|
||||
$processParams.credential = $credential
|
||||
}
|
||||
|
||||
return (Start-Process @processParams).ExitCode
|
||||
|
||||
return (Start-Process @processParams).ExitCode
|
||||
}
|
||||
|
||||
Function Invoke-Install {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Contains the Install Logic and return code handling from winget
|
||||
|
||||
|
||||
.PARAMETER Program
|
||||
The Winget ID of the Program that should be installed
|
||||
#>
|
||||
@ -117,14 +117,14 @@ Function Invoke-WinUtilWingetProgram {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Contains the Uninstall Logic and return code handling from winget
|
||||
|
||||
|
||||
.PARAMETER Program
|
||||
The Winget ID of the Program that should be uninstalled
|
||||
#>
|
||||
param (
|
||||
[psobject]$Program
|
||||
)
|
||||
|
||||
|
||||
try {
|
||||
$status = Invoke-Winget -wingetId $Program
|
||||
if ($status -eq 0) {
|
||||
@ -142,21 +142,21 @@ Function Invoke-WinUtilWingetProgram {
|
||||
|
||||
$count = $Programs.Count
|
||||
$failedPackages = @()
|
||||
|
||||
|
||||
Write-Host "==========================================="
|
||||
Write-Host "-- Configuring winget packages ---"
|
||||
Write-Host "==========================================="
|
||||
|
||||
|
||||
for ($i = 0; $i -lt $count; $i++) {
|
||||
$Program = $Programs[$i]
|
||||
$result = $false
|
||||
Set-WinUtilProgressBar -label "$Action $($Program)" -percent ($i / $count * 100)
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($i / $count)})
|
||||
|
||||
|
||||
$result = switch ($Action) {
|
||||
"Install" {Invoke-Install -Program $Program}
|
||||
"Uninstall" {Invoke-Uninstall -Program $Program}
|
||||
default {throw "[Install-WinUtilProgramWinget] Invalid action: $Action"}
|
||||
default {throw "[Install-WinUtilProgramWinget] Invalid action: $Action"}
|
||||
}
|
||||
|
||||
if (-not $result) {
|
||||
|
Reference in New Issue
Block a user