I'm trying to download application installers directly using PowerShell's invoke-webrequest instead of using winget or doing manual downloads. However, I'm facing an issue where the file I'm downloading seems corrupt and fails to run. Here's the command I've been using:
```powershell
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 also included a link with an image of the error I'm facing. I've read that using the -OutFile parameter might help, as shown in an edit I made, but I'm curious what exactly I should be doing to fix the downloading issue and ensure the installer works. Thanks for any insights!
1 Answer
You should be using the -OutFile parameter directly with invoke-webrequest instead of piping it to Out-File. It tends to handle the downloads more reliably that way. Also, try adding `$progresspreference='SilentlyContinue'` to speed up the process a bit!
Thanks for that tip! I'm curious, though—why does the -OutFile parameter work while piping to Out-File doesn't? It seems a bit odd.