Skip to content

Commit 97cfaa6

Browse files
authored
Fix example #1 for PS5.1 (#10830)
1 parent cbc1c9f commit 97cfaa6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 01/03/2024
5+
ms.date: 01/25/2024
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-WebRequest
@@ -16,12 +16,13 @@ Gets content from a web page on the internet.
1616
## SYNTAX
1717

1818
```
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>]
2526
```
2627

2728
## DESCRIPTION
@@ -49,10 +50,10 @@ This cmdlet was introduced in Windows PowerShell 3.0.
4950
This example uses the `Invoke-WebRequest` cmdlet to send a web request to the Bing.com site.
5051

5152
```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
5657
```
5758

5859
```Output
@@ -62,11 +63,10 @@ From Value 1
6263
To Value 5280
6364
```
6465

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.
7070

7171
### Example 2: Use a stateful web service
7272

0 commit comments

Comments
 (0)