diff --git a/Get-WinSCP.ps1 b/Get-WinSCP.ps1 index 41ef88a..7fbd115 100644 --- a/Get-WinSCP.ps1 +++ b/Get-WinSCP.ps1 @@ -11,7 +11,10 @@ if (Test-Path $zip) { Remove-Item $zip -Force } Write-Host "Downloading WinSCP from $url ..." try { - Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing + # winscp.net serves a human "please wait" landing page instead of the real + # file unless the User-Agent looks like a known download tool (curl/wget) - + # PowerShell's own default UA gets the landing page every time. + Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing -UserAgent "curl/8.0.1" } catch { Write-Host "ERROR: Download failed - $($_.Exception.Message)" -ForegroundColor Red Write-Host "Check your internet connection, or ask IT if winscp.net / sourceforge.net are blocked." -ForegroundColor Yellow @@ -21,7 +24,7 @@ try { $fileInfo = Get-Item $zip if ($fileInfo.Length -lt 1MB) { Write-Host "ERROR: Downloaded file is only $($fileInfo.Length) bytes - too small to be WinSCP." -ForegroundColor Red - Write-Host "This usually means antivirus, a firewall, or a web filter intercepted the download and replaced it with a block/warning page instead of letting the real file through." -ForegroundColor Yellow + Write-Host "This is usually winscp.net serving its 'please wait' landing page instead of the real file, or antivirus/a firewall intercepting the download." -ForegroundColor Yellow $preview = Get-Content -Path $zip -TotalCount 15 -ErrorAction SilentlyContinue if ($preview) {