How to speed up PowerShell Invoke-WebRequest

July 28, 2022

So I was setting up a small Jenkins task where I needed a DB backup I should download, unzip, etc. I played with Invoke-WebRequest a bit and it turns out that default behavior of displaying the progressbar on top of window will not only make things super slow but will also not download my file if the file is bigger (mine is about 800MB+ zip file).

From quick search I found out that this is well known problem (7+ years): https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download

or

https://github.com/PowerShell/PowerShell/issues/2138

but… in discussions I saw a quick fix which consist of setting one extra property :

$ProgressPreference = 'SilentlyContinue'

or making a backup of $ProgressPreference state before download and then calling Invoke-WebRequest is the key to download file as fast as browser and to download it succesfully in one piece.

Why this is not a parameter to Invoke-WebRequest is unknown and I am not sure if I am ready for truth behind this great decision.

Hope this helps.


Profile picture

Written by Dušan Roštár - the "mr edge case" guy
my twitter : rostacik, my linkedin : rostar
Reach me at dusan at thisdomain.net