Skip to content

Instantly share code, notes, and snippets.

@ctigeek
Created November 1, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctigeek/5413faf40f11e8b9aeee6f3d6725650d to your computer and use it in GitHub Desktop.
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