Public Access
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.
This commit is contained in:
+5
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user