From 0e5943c2079b7b185ea61fef018457d7e3e7f729 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Wed, 17 Jul 2024 23:42:44 +0300 Subject: [PATCH] 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 --- functions/private/Install-WinUtilProgramWinget.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/private/Install-WinUtilProgramWinget.ps1 b/functions/private/Install-WinUtilProgramWinget.ps1 index 08d1d611..fc854eca 100644 --- a/functions/private/Install-WinUtilProgramWinget.ps1 +++ b/functions/private/Install-WinUtilProgramWinget.ps1 @@ -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.