PowerShell: Get-WebResponseStatusText
function Get-WebResponseStatusText {
[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="None")]
PARAM(
[int]
$Code
)
switch ($Code) {
<# Informational #>
100 {$WebResponseStatus = "Continue"}
101 {$WebResponseStatus = "Switching Protocols"}
102 {$WebResponseStatus = "Processing"}
<# Success #>
200 {$WebResponseStatus = "OK"}
201 {$WebResponseStatus = "Created"}
202 {$WebResponseStatus = "Accepted"}
203 {$WebResponseStatus = "Non-authoritative Information"}
204 {$WebResponseStatus = "No Content"}
205 {$WebResponseStatus = "Reset Content"}
206 {$WebResponseStatus = "Partial Content"}
207 {$WebResponseStatus = "Multi-Status"}
208 {$WebResponseStatus = "Already Reported"}
226 {$WebResponseStatus = "IM Used"}
<# Redirection #>
300 {$WebResponseStatus = "Multiple Choices"}
301 {$WebResponseStatus = "Moved Permanently"}
302 {$WebResponseStatus = "Found"}
303 {$WebResponseStatus = "See Other"}
304 {$WebResponseStatus = "Not Modified"}
305 {$WebResponseStatus = "Use Proxy"}
307 {$WebResponseStatus = "Temporary Redirect"}
308 {$WebResponseStatus = "Permanent Redirect"}
<# Client Error #>
400 {$WebResponseStatus = "Bad Request"}
401 {$WebResponseStatus = "Unauthorized"}
402 {$WebResponseStatus = "Payment Required"}
403 {$WebResponseStatus = "Forbidden"}
404 {$WebResponseStatus = "Not Found"}
405 {$WebResponseStatus = "Method Not Allowed"}
406 {$WebResponseStatus = "Not Acceptable"}
407 {$WebResponseStatus = "Proxy Authentication Required"}
408 {$WebResponseStatus = "Request Timeout"}
409 {$WebResponseStatus = "Conflict"}
410 {$WebResponseStatus = "Gone"}
411 {$WebResponseStatus = "Length Required"}
412 {$WebResponseStatus = "Precondition Failed"}
413 {$WebResponseStatus = "Payload Too Large"}
414 {$WebResponseStatus = "Request-URI Too Long"}
415 {$WebResponseStatus = "Unsupported Media Type"}
416 {$WebResponseStatus = "Requested Range Not Satisfiable"}
417 {$WebResponseStatus = "Expectation Failed"}
418 {$WebResponseStatus = "I'm a teapot"}
421 {$WebResponseStatus = "Misdirected Request"}
422 {$WebResponseStatus = "Unprocessable Entity"}
423 {$WebResponseStatus = "Locked"}
424 {$WebResponseStatus = "Failed Dependency"}
426 {$WebResponseStatus = "Upgrade Required"}
428 {$WebResponseStatus = "Precondition Required"}
429 {$WebResponseStatus = "Too Many Requests"}
431 {$WebResponseStatus = "Request Header Fields Too Large"}
451 {$WebResponseStatus = "Unavailable For Legal Reasons"}
499 {$WebResponseStatus = "Client Closed Request"}
<# Server Error #>
500 {$WebResponseStatus = "Internal Server Error"}
501 {$WebResponseStatus = "Not Implemented"}
502 {$WebResponseStatus = "Bad Gateway"}
503 {$WebResponseStatus = "Service Unavailable"}
504 {$WebResponseStatus = "Gateway Timeout"}
505 {$WebResponseStatus = "HTTP Version Not Supported"}
506 {$WebResponseStatus = "Variant Also Negotiates"}
507 {$WebResponseStatus = "Insufficient Storage"}
508 {$WebResponseStatus = "Loop Detected"}
510 {$WebResponseStatus = "Not Extended"}
511 {$WebResponseStatus = "Network Authentication Required"}
599 {$WebResponseStatus = "Network Connect Timeout Error"}
default {$WebResponseStatus = "Unknown Response"}
}
$WebResponseStatus
}