Checking Website Availability with a PowerShell Function In the previous example we created a small PowerShell function that checks web site availability, and as part...
Checking Website Availability with a PowerShell Function
In the previous example we created a small PowerShell function that checks web site availability, and as part of the test results, a HTTP response code was returned. Let’s check out how this numeric code can be easily converted into a meaningful text message.
In this example, the response code is “200” which happens to stand for “OK”. If you’d like to convert HTTP response codes to text, simply convert the data type to [System.Net.HttpStatusCode]. That’s all:
PS C:\> 200 -as [System.Net.HttpStatusCode]
OK
Here is a version that incorporates this conversion for you: