Forrest logo
back to the Invoke-WebRequest tool

invoke-webrequest:tldr:ac4f3

invoke-webrequest: Download the contents of a URL to a file.
$ Invoke-WebRequest ${http:--example-com} -OutFile ${path\to\file}
try on your machine

The given command is written in Windows PowerShell scripting language. It is used to invoke a web request to a specified URL and save the response to a file.

Here is a breakdown of the command:

  1. Invoke-WebRequest: This is a PowerShell cmdlet used to send HTTP and HTTPS requests to a web page or web service.

  2. ${http:--example-com}: This represents the URL or web address to which the web request is sent. In this case, it is set to http://example.com. The ${} syntax is used to enclose and evaluate variables within the command.

  3. -OutFile: This is a parameter used to specify the output file where the content of the web request will be saved.

  4. ${path\to\file}: This represents the file path and name to which the response content will be saved. In this case, it is set to path\to\file. Similar to the previous variable, ${} is used to evaluate the path variable.

To use this command, you would replace ${http:--example-com} with the desired URL and ${path\to\file} with the desired file path and name where the content should be saved. For example:

Invoke-WebRequest http://example.com -OutFile C:\path\to\file.txt

In this case, the web request is sent to http://example.com and the response content is saved to the file C:\path\to\file.txt.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the Invoke-WebRequest tool