File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,7 +147,25 @@ $msi = "PowerShell-$($env:REQUESTED_VERSION)-win-x64.msi"
147147$url = " https://github.com/PowerShell/PowerShell/releases/download/v$ ( $env: REQUESTED_VERSION ) /$msi "
148148Write-Host " Downloading from: $url "
149149
150- $null = Invoke-WebRequest - Uri $url - OutFile $msi - UseBasicParsing - ErrorAction Stop
150+ $downloadSucceeded = $false
151+ $maxAttempts = 3
152+ for ($attempt = 1 ; $attempt -le $maxAttempts ; $attempt ++ ) {
153+ try {
154+ $null = Invoke-WebRequest - Uri $url - OutFile $msi - UseBasicParsing - ErrorAction Stop
155+ $downloadSucceeded = $true
156+ break
157+ } catch {
158+ if ($attempt -eq $maxAttempts ) {
159+ throw
160+ }
161+ Write-Host " Warning: Download attempt $attempt failed; retrying..."
162+ }
163+ }
164+
165+ if (-not $downloadSucceeded ) {
166+ Write-Host ' Error: Failed to download PowerShell package after retry attempts.'
167+ exit 1
168+ }
151169
152170# Install requested version
153171Write-Host " Starting installation of PowerShell [$ ( $env: REQUESTED_VERSION ) ]..."
Original file line number Diff line number Diff line change 99 [string ] $GitHubToken
1010)
1111
12+ <#
13+ . SYNOPSIS
14+ Builds GitHub API request headers for optional authenticated requests.
15+ #>
1216function Get-GitHubApiHeader {
1317 [CmdletBinding ()]
18+ [OutputType ([hashtable ])]
1419 param (
1520 [Parameter ()]
1621 [string ] $Token
@@ -28,8 +33,13 @@ function Get-GitHubApiHeader {
2833 return $headers
2934}
3035
36+ <#
37+ . SYNOPSIS
38+ Resolves symbolic input values (latest/prerelease) to a concrete PowerShell version.
39+ #>
3140function Resolve-ExpectedVersion {
3241 [CmdletBinding ()]
42+ [OutputType ([string ])]
3343 param (
3444 [Parameter (Mandatory )]
3545 [string ] $Version ,
You can’t perform that action at this time.
0 commit comments