powershelldefaultfile-locationinvoke-webrequest

Invoke-WebRequest without OutFile?


I used Invoke-WebRequest in Powershell to download a file without using the -OutFile parameter, and, from the documentation here, the file should've ended up in the directory I was in. However, there is nothing. Response was OK, no error was shown.

What could've happened to that file? Am I mistaken about how Invoke-WebRequest should work without an Out parameter?

Thanks!

Note: I know I can easily download the file using the parameter, but it's pretty big and I'd like to make sure it doesn't end up clogging disk space somewhere I don't need


Solution

  • From the linked docs:

    By default, Invoke-WebRequest returns the results to the pipeline.

    That is, in the absence of -OutFile no file is created.
    (If you don't capture or redirect the output, it will print to the host (console).)

    As techguy1029 notes in a comment on the question, the current directory only comes into play if you do use
    -OutFile but specify a mere file name rather than a path.

    Additionally:


    As an aside: