Author Posts

June 2, 2015 at 10:15 am

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?


June 2, 2015 at 12:03 pm

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.