powershellamazon-ec2amazon-s3powershell-3.0

Powershell - Why is Using Invoke-WebRequest Much Slower Than a Browser Download?


I use Powershell's Invoke-WebRequest method to download a file from Amazon S3 to my Windows EC2 instance.

If I download the file using Chrome, I am able to download a 200 MB file in 5 seconds. The same download in PowerShell using Invoke-WebRequest takes up to 5 minutes.

Why is using Invoke-WebRequest slower and is there a way to download at full speed in a PowerShell script?


Solution

  • I was using

    Invoke-WebRequest $video_url -OutFile $local_video_url
    

    I changed the above to

    $wc = New-Object net.webclient
    $wc.Downloadfile($video_url, $local_video_url)
    

    This restored the download speed to what I was seeing in my browsers.