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

38 lines
1.2 KiB
PowerShell
Raw Normal View History

+3
2023-03-07 12:28:00 -08:00
Function Install-WinUtilProgramWinget {
<#
.DESCRIPTION
This will install programs via Winget using a new powershell.exe instance to prevent the GUI from locking up.
Note the triple quotes are required any time you need a " in a normal script block.
#>
+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 ",")){
+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"){
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait
}
if($manage -eq "Uninstalling"){
Start-Process -FilePath winget -ArgumentList "remove -e --purge --force --silent $Program" -NoNewWindow -Wait
}
+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
}