-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Closed
Copy link
Labels
area-archiveArea - Microsoft.PowerShell.Archive moduleArea - Microsoft.PowerShell.Archive modulearea-utilityArea - Microsoft.PowerShell.Utility moduleArea - Microsoft.PowerShell.Utility module
Description
Issue Details
As @markekraus mentions in PowerShell/PowerShell#9009, the Invoke-WebRequest cmdlet+ is designed to emit a terminating error when a non-success code is received:
A non-success HTTP status message throws terminating errors and does not return any output. You must do something like this:
try {
$response = invoke-WebRequest -Uri $Uri -ErrorAction Stop
$StatusCode = $Response.StatusCode
} catch {
$StatusCode = $_.Exception.Response.StatusCode.value__
}Something along these lines should be added to the documentation to give clear indication of the behaviour and how to handle it appropriately.
Version(s) of document impacted
- Impacts 6.next document
- Impacts 6 document
- Impacts 5.1 document
- Impacts 5.0 document
- Impacts 4.0 document
- Impacts 3.0 document
Reason(s) for not selecting all version of documents
- The documented feature was introduced in selected version of PowerShell
- This issue only shows up in selected version of the document
Metadata
Metadata
Assignees
Labels
area-archiveArea - Microsoft.PowerShell.Archive moduleArea - Microsoft.PowerShell.Archive modulearea-utilityArea - Microsoft.PowerShell.Utility moduleArea - Microsoft.PowerShell.Utility module