Created
November 21, 2024 17:01
-
-
Save MudraR/cc6db9b1bc6428695aa83608eeec48a8 to your computer and use it in GitHub Desktop.
Get Detailed Web Response via PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Url = "https://google.com" | |
| try { | |
| $response = Invoke-WebRequest $Url -UseBasicParsing -UseDefaultCredentials | |
| $statusCode = $response.StatusCode | |
| $responseContent = $response.Content | |
| $responseHeaders = $response.Headers | |
| $responseRawContent = $response.RawContent | |
| $responseAllProperties = $response | Select-Object * | |
| } catch { | |
| $statusCode = $_.Exception.Response.StatusCode | |
| $errorMessage = $_.Exception.Message | |
| $responseAllProperties = $_.Exception.Response | Select-Object * | |
| } | |
| $responseAllProperties |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment