Add Extra Guards/Checks in 'Install-WinUtilProgramChoco' Private Function

This commit is contained in:
Mr.k 2024-05-11 20:09:49 +03:00 committed by Kian
parent e69048a7a0
commit 782fca962e
No known key found for this signature in database

View File

@ -14,13 +14,21 @@ function Install-WinUtilProgramChoco {
#> #>
param( param(
$ProgramsToInstall, [Parameter(Mandatory, Position=0)]
$manage = "Installing" [PsCustomObject]$ProgramsToInstall,
[Parameter(Mandatory, Position=1)]
[String]$manage = "Installing"
) )
$x = 0 $x = 0
$count = $ProgramsToInstall.Count $count = $ProgramsToInstall.Count
# This check isn't really necessary, as there's a couple of checks before this Private Function gets called, but just to make sure ;)
if($count -le 0) {
throw "Private Function 'Install-WinUtilProgramChoco' expected Parameter 'ProgramsToInstall' to be of size 1 or greater, instead got $count,`nPlease double check your code and re-compile WinUtil."
}
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0 Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- insstalling Chocolatey pacakages ---" Write-Host "-- insstalling Chocolatey pacakages ---"