Show a preview of blocked/substituted downloads in Get-WinSCP.ps1

The 1MB size-check catches a bad download but gave no way to see why - on a
locked-down network something is very likely substituting a small HTML page
(proxy/AV block page) for the real zip. Print the first lines of whatever
was actually saved so the content is visible without another round trip.
This commit is contained in:
2026-07-05 19:30:08 -05:00
parent 3ac8bf287c
commit 0805011ac6
+12 -2
View File
@@ -21,8 +21,18 @@ 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 or a firewall blocked/altered the download instead of letting the real file through." -ForegroundColor Yellow
Write-Host "Try running setup.bat again. If it keeps happening, download WinSCP-6.3.6-Automation.zip manually from winscp.net and unzip it into:" -ForegroundColor Yellow
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
$preview = Get-Content -Path $zip -TotalCount 15 -ErrorAction SilentlyContinue
if ($preview) {
Write-Host ""
Write-Host "--- What was actually downloaded (first 15 lines, for troubleshooting) ---" -ForegroundColor Yellow
$preview | ForEach-Object { Write-Host $_ }
Write-Host "--- end ---" -ForegroundColor Yellow
Write-Host ""
}
Write-Host "Try running setup.bat again. If it keeps happening, ask IT whether winscp.net / sourceforge.net downloads are being blocked, or download WinSCP-6.3.6-Automation.zip manually in a browser and unzip it into:" -ForegroundColor Yellow
Write-Host " $dest" -ForegroundColor Yellow
Remove-Item $zip -Force
exit 1