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/03 /2024
5
+ ms.date : 01/25 /2024
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
title : Invoke-WebRequest
@@ -16,12 +16,13 @@ Gets content from a web page on the internet.
16
16
## SYNTAX
17
17
18
18
```
19
- Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-WebSession <WebRequestSession>] [-SessionVariable <String>]
20
- [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>]
21
- [-Certificate <X509Certificate>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>]
22
- [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-Method <WebRequestMethod>] [-Proxy <Uri>]
23
- [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] [-ContentType <String>]
24
- [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [<CommonParameters>]
19
+ Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-WebSession <WebRequestSession>]
20
+ [-SessionVariable <String>] [-Credential <PSCredential>] [-UseDefaultCredentials]
21
+ [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-UserAgent <String>]
22
+ [-DisableKeepAlive] [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>]
23
+ [-Method <WebRequestMethod>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>]
24
+ [-ProxyUseDefaultCredentials] [-Body <Object>] [-ContentType <String>] [-TransferEncoding <String>]
25
+ [-InFile <String>] [-OutFile <String>] [-PassThru] [<CommonParameters>]
25
26
```
26
27
27
28
## DESCRIPTION
@@ -49,10 +50,10 @@ This cmdlet was introduced in Windows PowerShell 3.0.
49
50
This example uses the ` Invoke-WebRequest ` cmdlet to send a web request to the Bing.com site.
50
51
51
52
``` powershell
52
- $Response = Invoke-WebRequest -URI https://www.bing.com?q=how+many+feet+in+a+mile
53
- $Response.AllElements | Where-Object {
54
- $_. name -like "* Value" -and $_.tagName -eq "INPUT"
55
- } | Select-Object Name, Value
53
+ $Response = Invoke-WebRequest -UseBasicParsing - URI https://www.bing.com?q=how+many+feet+in+a+mile
54
+ $Response.InputFields |
55
+ Where-Object name -like "* Value" |
56
+ Select-Object name, value
56
57
```
57
58
58
59
``` Output
@@ -62,11 +63,10 @@ From Value 1
62
63
To Value 5280
63
64
```
64
65
65
- The first command issues the request and saves the response in the ` $Response ` variable.
66
-
67
- The second command filters the objects in the ** AllElements** property where the ** name** property
68
- is like "* Value" and the ** tagName** is "INPUT". The filtered results are piped to ` Select-Object `
69
- to select the ** name** and ** value** properties.
66
+ The data returned by ` Invoke-WebRequest ` is stored in the ` $Response ` variable. The ** InputFields**
67
+ property of the response contains the form fields. ` Where-Object ` is used to filter the form fields
68
+ to those where the ** name** property is like "* Value". The filtered results are piped to
69
+ ` Select-Object ` to select the ** name** and ** value** properties.
70
70
71
71
### Example 2: Use a stateful web service
72
72
0 commit comments