How can I use Invoke-WebRequest to download a file but automatically make the file name the same as if I downloaded via browser? I haven't found a way to make -OutFile work without manually specifying the file name. I'm fine with this involving a few other lines of code.
A good solution will:
- Work even if the file name isn't in the request URL. For example, the URL to download the Visual Studio x64 Remote Debugging Tools is
http://go.microsoft.com/fwlink/?LinkId=393217but it downloads the filertools_setup_x64.exe. - Not save the whole file to memory before writing to disk, unless that's what Invoke-WebRequest already does even with the -OutFile parameter (?)
Thanks!
http://download.microsoft.com/download/D/2/8/D28C6482-555B-4777-876F-85897C071FB6/rtools_setup_x64.exewgetandcurldo just that and it's a simple expectation of any command that downloads a URL to a filename. Many services will serve a "file" but behind a URL that doesn't itself contain the filename.