mirror of
https://github.com/vale981/ray
synced 2025-03-10 13:26:39 -04:00
32 lines
No EOL
902 B
PowerShell
32 lines
No EOL
902 B
PowerShell
function Choco-Install {
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string] $PackageName,
|
|
[string[]] $ArgumentList,
|
|
[int] $RetryCount = 5
|
|
)
|
|
|
|
process {
|
|
$count = 1
|
|
while($true)
|
|
{
|
|
Write-Host "Running [#$count]: choco install $packageName -y $argumentList"
|
|
choco install $packageName -y @argumentList --no-progress
|
|
|
|
$pkg = choco list --localonly $packageName --exact --all --limitoutput
|
|
if ($pkg) {
|
|
Write-Host "Package installed: $pkg"
|
|
break
|
|
}
|
|
else {
|
|
$count++
|
|
if ($count -ge $retryCount) {
|
|
Write-Host "Could not install $packageName after $count attempts"
|
|
exit 1
|
|
}
|
|
Start-Sleep -Seconds 30
|
|
}
|
|
}
|
|
}
|
|
} |