Using Powershell version 4.0 I'm trying to download Firefox browser programatically:
$uri = "https://www.mozilla.org/en-US/firefox/new/?scene=2"
$out = "C:\Users\bhatsubh\Downloads\Firefox Setup Stub 48.0.2.exe"
Invoke-WebRequest -Uri $uri -OutFile $out
But it is not downloading the correct file. Instead the file is the wrong one with a size of 65 KB.
When I copy-paste the URL in the web browser the download starts automatically and the correct file is downloaded with a size of 237 KB.
The site uses javascript to start the download, so the wrong file you're getting is actually HTML page. Looking at its source we can see the actual link of setup "stub":
https://download.mozilla.org/?product=firefox-stub&os=win&lang=en-US
It's also possible to download the full installer:
https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US