Forrest logo
back to the Invoke-WebRequest tool

invoke-webrequest:tldr:bee63

invoke-webrequest: Send a request with an extra header, using a custom HTTP method.
$ Invoke-WebRequest -Headers ${@{ X-My-Header = '123' }} -Method ${PUT} ${http:--example-com}
try on your machine

The given command is written in PowerShell language and it can be explained as follows:

  • Invoke-WebRequest: It is a PowerShell cmdlet that allows you to send HTTP requests to a specified URI or web address.

  • -Headers ${@{ X-My-Header = '123' }}: This parameter is used to specify the headers for the HTTP request. In this case, it sets the value of the X-My-Header header to '123'. The syntax ${@{ X-My-Header = '123' }} is used to create a hashtable (dictionary) in PowerShell.

  • -Method ${PUT}: This parameter is used to specify the HTTP method to be used in the request. In this case, it sets the method to PUT. The syntax ${PUT} is likely a variable that holds the value 'PUT'.

  • ${http:--example-com}: This specifies the URI or URL of the target web address. The hyphens in the URL (http:--example-com) appear to be a typographical error and should be replaced with colons (http://example.com).

To summarize, the command makes an HTTP PUT request to http://example.com with a custom header X-My-Header set to '123'.

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