Using Invoke-webrequest to download a zip file

This topic contains 1 reply, has 1 voice, and was last updated by  Greg Martin 2 years, 11 months ago.

  • Author
  • #25888

    Greg Martin

    I'm looking to download a zip file from a website. I can do that using something like this:

    invoke-webrequest "$sourceURI" -outfile "$destinationfilename"

    however, I would like to see the headers.

    I know I can capture the output in a variable like so:

    $output = invoke-webrequest "$source$dailyfilename" -outfile "$destination$dailyfilename"

    But it is always empty when I use outfile.

    So if I skip the outfile, how do I get the content stream into a file?


  • #25890

    Greg Martin

    Spoke with Jeff Hicks on Twitter (@JeffHicks) and he gave this solution:

    $output = invoke-webrequest "$sourceURI" -outfile "$destinationfilename" -passthru | select -Expand headers

    With this $output has the headers for my subsequent use.

You must be logged in to reply to this topic.