|
2 | 2 | external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml |
3 | 3 | Locale: en-US |
4 | 4 | Module Name: Microsoft.PowerShell.Utility |
5 | | -ms.date: 01/25/2024 |
| 5 | +ms.date: 10/29/2025 |
6 | 6 | online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1&WT.mc_id=ps-gethelp |
7 | 7 | schema: 2.0.0 |
8 | 8 | aliases: |
@@ -37,15 +37,12 @@ significant HTML elements. |
37 | 37 |
|
38 | 38 | This cmdlet was introduced in Windows PowerShell 3.0. |
39 | 39 |
|
40 | | -> [!NOTE] |
41 | | -> By default, script code in the web page may be run when the page is being parsed to populate the |
42 | | -> `ParsedHtml` property. Use the `-UseBasicParsing` switch to suppress this. |
| 40 | +> [!WARNING] |
| 41 | +> By default, `Invoke-WebRequest` parses the content of the web page. Script code in the web page |
| 42 | +> might be run when the page is parsed. Use the `-UseBasicParsing` switch to avoid script code |
| 43 | +> execution. |
43 | 44 |
|
44 | | -> [!IMPORTANT] |
45 | | -> The examples in this article reference hosts in the `contoso.com` domain. This is a fictitious |
46 | | -> domain used by Microsoft for examples. The examples are designed to show how to use the cmdlets. |
47 | | -> However, since the `contoso.com` sites don't exist, the examples don't work. Adapt the examples |
48 | | -> to hosts in your environment. |
| 45 | +This command can be run using the `iwr`, `curl`, or `wget` aliases. |
49 | 46 |
|
50 | 47 | ## EXAMPLES |
51 | 48 |
|
@@ -155,7 +152,7 @@ $StatusCode |
155 | 152 | The terminating error is caught by the `catch` block, which retrieves the **StatusCode** from the |
156 | 153 | **Exception** object. |
157 | 154 |
|
158 | | -### Example 8: Download multiple files at the same time |
| 155 | +### Example 5: Download multiple files at the same time |
159 | 156 |
|
160 | 157 | The `Invoke-WebRequest` cmdlet can only download one file at a time. The following example uses |
161 | 158 | `Start-ThreadJob` to create multiple thread jobs to download multiple files at the same time. |
@@ -221,13 +218,13 @@ request content to the form fields. |
221 | 218 | For example: |
222 | 219 |
|
223 | 220 | `$r = Invoke-WebRequest https://website.com/login.aspx` |
224 | | -`$r.Forms\[0\].Name = "MyName"` |
225 | | -`$r.Forms\[0\].Password = "MyPassword"` |
| 221 | +`$r.Forms[0].Name = "MyName"` |
| 222 | +`$r.Forms[0].Password = "MyPassword"` |
226 | 223 | `Invoke-RestMethod https://website.com/service.aspx -Body $r` |
227 | 224 |
|
228 | 225 | - or - |
229 | 226 |
|
230 | | -`Invoke-RestMethod https://website.com/service.aspx -Body $r.Forms\[0\]` |
| 227 | +`Invoke-RestMethod https://website.com/service.aspx -Body $r.Forms[0]` |
231 | 228 |
|
232 | 229 | ```yaml |
233 | 230 | Type: System.Object |
@@ -761,6 +758,8 @@ This cmdlet returns the response object representing the result of the web reque |
761 | 758 | Windows PowerShell includes the following aliases for `Invoke-WebRequest`: |
762 | 759 |
|
763 | 760 | - `iwr` |
| 761 | +- `curl` |
| 762 | +- `wget` |
764 | 763 |
|
765 | 764 | ## RELATED LINKS |
766 | 765 |
|
|
0 commit comments