ModsMode for Install/Upgrade

pull/134/head
KnifMelti 2022-07-28 19:09:50 +02:00
parent 7e38b02d98
commit ab6d29dadd
1 changed files with 11 additions and 1 deletions

View File

@ -19,6 +19,9 @@ Function Update-App ($app) {
#Run Winget Upgrade command #Run Winget Upgrade command
& $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Set mods to apply as an upgrade
$ModsMode = "Upgrade"
#Check if application updated properly #Check if application updated properly
$CheckOutdated = Get-WingetOutdatedApps $CheckOutdated = Get-WingetOutdatedApps
$FailedToUpgrade = $false $FailedToUpgrade = $false
@ -28,6 +31,9 @@ Function Update-App ($app) {
#If app failed to upgrade, run Install command #If app failed to upgrade, run Install command
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Set mods to apply as an install
$ModsMode = "Install"
#Check if application installed properly #Check if application installed properly
$CheckOutdated2 = Get-WingetOutdatedApps $CheckOutdated2 = Get-WingetOutdatedApps
foreach ($CheckApp2 in $CheckOutdated2) { foreach ($CheckApp2 in $CheckOutdated2) {
@ -42,10 +48,14 @@ Function Update-App ($app) {
#Check if mods exist for install/upgrade #Check if mods exist for install/upgrade
$ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id)
if ($ModsUpgrade) { if ($ModsMode = "Upgrade") {
Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow"
& "$ModsUpgrade" & "$ModsUpgrade"
} }
elseif ($ModsMode = "Install") {
Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow"
& "$ModsInstall"
}
} }
Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray"