From a92dc68cb99ccbe9d386a882511ef83004f0ba3a Mon Sep 17 00:00:00 2001 From: Brad Lance Date: Sun, 5 Jul 2026 19:34:14 -0500 Subject: [PATCH] Fix WinSCP download by spoofing a curl-like User-Agent Root cause found: winscp.net's download URL serves a human "please wait" landing page (18KB HTML) instead of redirecting to the real file, unless the User-Agent contains a known download-tool signature like curl or Wget. PowerShell's own default UA always gets the landing page - confirmed by reproducing locally with various UAs against the live URL. Not antivirus, not TLS, not a network block; overriding -UserAgent to a curl string on Invoke-WebRequest resolves it. --- Get-WinSCP.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) {