Files
winutil/functions/private/Install-WinUtilProgramWinget.ps1
T

45 lines
1.3 KiB
PowerShell
Raw Normal View History

+3
2023-03-07 12:28:00 -08:00
Function Install-WinUtilProgramWinget {
<#
2023-10-19 17:12:55 -05:00
.SYNOPSIS
Manages the provided programs using Winget
.PARAMETER ProgramsToInstall
A list of programs to manage
.PARAMETER manage
The action to perform on the programs, can be either 'Installing' or 'Uninstalling'
.NOTES
The triple quotes are required any time you need a " in a normal script block.
+3
2023-03-07 12:28:00 -08:00
#>
+2
2023-05-09 13:14:27 -05:00
param(
$ProgramsToInstall,
$manage = "Installing"
)
+3
2023-03-07 12:28:00 -08:00
$x = 0
$count = $($ProgramsToInstall -split ",").Count
+2
2023-05-09 13:14:27 -05:00
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
+3
2023-03-07 12:28:00 -08:00
Foreach ($Program in $($ProgramsToInstall -split ",")){
2023-10-19 17:12:55 -05:00
+2
2023-05-09 13:14:27 -05:00
Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100)
if($manage -eq "Installing"){
+5
2024-01-25 14:44:51 -06:00
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --scope=machine --silent $Program" -NoNewWindow -Wait
+2
2023-05-09 13:14:27 -05:00
}
if($manage -eq "Uninstalling"){
Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait
+2
2023-05-09 13:14:27 -05:00
}
2023-10-19 17:12:55 -05:00
+3
2023-03-07 12:28:00 -08:00
$X++
}
+2
2023-05-09 13:14:27 -05:00
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
+3
2023-03-07 12:28:00 -08:00
}