I'm trying to download application installers directly from websites using PowerShell instead of going through winget or manual downloads. However, I'm running into an issue where the downloaded file seems to be corrupt and doesn't work. Here's the command I'm using:
```
invoke-webrequest -Uri https://download-installer.cdn.mozilla.net/pub/firefox/releases/138.0.1/win32/en-US/Firefox%20Installer.exe | out-file C:tempff2.exe
```
I've included a screenshot of the error I get too!
After some testing, I found that my original command wasn't working, but I got it to work using the `-OutFile` parameter instead:
```
invoke-webrequest -Uri https://download-installer.cdn.mozilla.net/pub/firefox/releases/138.0.1/win32/en-US/Firefox%20Installer.exe -OutFile C:tempff2.exe
```
Now it seems to work fine, but I'm curious about what was wrong with my initial command.
2 Answers
Now that you have a working solution, I'm curious: what makes you prefer downloading directly instead of using package managers like winget or choco? They handle updates for you, which seems like a lot less hassle in the long run!
It looks like you just needed to use the `-OutFile` parameter directly instead of piping it to `Out-File`. When you pipe the output, it can lead to issues with how the data is handled, which is likely why the file ended up being corrupt. Also, if you're looking for speed, try setting `$progresspreference='SilentlyContinue'` before running your command to make it faster!
I get that, but I sometimes need specific versions of software, especially for work-related tools that are tied to accounts or licenses. Those package managers often don't have the versions I need for certain applications.