File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ if /i not "%confirm%"=="Y" goto MENU
274274
275275echo .
276276echo Downloading...
277- powershell -NoProfile -ExecutionPolicy Bypass -Command " $ProgressPreference='SilentlyContinue'; try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%DOWNLOAD_URL% ' - OutFile '%ZIP_FILE% ' - TimeoutSec %DOWNLOAD_TIMEOUT_SEC% ; Write-Host 'Download complete' -ForegroundColor Green } catch { Write-Host ('ERROR: ' + $_.Exception.Message) -ForegroundColor Red; exit 1 }"
277+ powershell -NoProfile -ExecutionPolicy Bypass -Command " $ProgressPreference='SilentlyContinue'; try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $iwc = Get-Command Invoke-WebRequest -ErrorAction SilentlyContinue; $p = @{ Uri = '%DOWNLOAD_URL% '; OutFile = '%ZIP_FILE% ' }; if ($iwc -and $iwc.Parameters.ContainsKey('UseBasicParsing')) { $p.UseBasicParsing = $true }; if ($iwc -and $iwc.Parameters.ContainsKey(' TimeoutSec')) { $p.TimeoutSec = %DOWNLOAD_TIMEOUT_SEC% }; Invoke-WebRequest @p ; Write-Host 'Download complete' -ForegroundColor Green } catch { Write-Host ('ERROR: ' + $_.Exception.Message) -ForegroundColor Red; exit 1 }"
278278
279279if errorlevel 1 (
280280 echo .
Original file line number Diff line number Diff line change @@ -537,7 +537,12 @@ function Test-NetworkSpeed {
537537 $tempFile = [System.IO.Path ]::GetTempFileName()
538538 Write-Host " Running internet download test (~10MB)..." - ForegroundColor Yellow
539539 $stopwatch = [System.Diagnostics.Stopwatch ]::StartNew()
540- Invoke-WebRequest - Uri $testUrl - OutFile $tempFile - UseBasicParsing - TimeoutSec 120 | Out-Null
540+ # Use compatible parameters across PowerShell versions
541+ $iwc = Get-Command Invoke-WebRequest - ErrorAction SilentlyContinue
542+ $iwParams = @ { Uri = $testUrl ; OutFile = $tempFile }
543+ if ($iwc -and $iwc.Parameters.ContainsKey (' UseBasicParsing' )) { $iwParams.UseBasicParsing = $true }
544+ if ($iwc -and $iwc.Parameters.ContainsKey (' TimeoutSec' )) { $iwParams.TimeoutSec = 120 }
545+ Invoke-WebRequest @iwParams | Out-Null
541546 $stopwatch.Stop ()
542547
543548 $fileInfo = Get-Item $tempFile
You can’t perform that action at this time.
0 commit comments