Skip to content

Instantly share code, notes, and snippets.

@MudraR
Created November 21, 2024 17:01
Show Gist options
  • Select an option

  • Save MudraR/cc6db9b1bc6428695aa83608eeec48a8 to your computer and use it in GitHub Desktop.

Select an option

Save MudraR/cc6db9b1bc6428695aa83608eeec48a8 to your computer and use it in GitHub Desktop.
Get Detailed Web Response via PowerShell
$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