Skip to content

Instantly share code, notes, and snippets.

@ctigeek
Created November 1, 2016 15:02
Show Gist options
  • Select an option

  • Save ctigeek/5413faf40f11e8b9aeee6f3d6725650d to your computer and use it in GitHub Desktop.

Select an option

Save ctigeek/5413faf40f11e8b9aeee6f3d6725650d to your computer and use it in GitHub Desktop.
GET the response code from a URL.
function Get-ResponseCode($url) {
try {
$response = Invoke-WebRequest $url
$response.StatusCode
}
catch {
$_.Exception.Response.StatusCode.Value__
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment