Fix Off By One Error by Replaceing Wrong Comparison Operator from '-le' (Less or Equal) to '-lt' (Less Than) in For Loop of 'Install-WinUtilProgramWinget' Private Function

This commit is contained in:
Mr.k 2024-07-17 23:42:44 +03:00
parent 6aaebef4b9
commit 0e5943c207
No known key found for this signature in database

View File

@ -29,10 +29,10 @@ Function Install-WinUtilProgramWinget {
Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---"
Write-Host "==========================================="
for ($i = 0; $i -le $ProgramsToInstall.Count; $i++) {
for ($i = 0; $i -lt $count; $i++) {
$Program = $ProgramsToInstall[$i]
$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) $($i + 1) of $count" -PercentComplete $((($i + 1)/$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.