I know of a few good ways to build web clients in PowerShell: the .NET classes System.Net.WebClient and System.Net.HttpWebRequest, or the COM object Msxml2.XMLHTTP. From what I
Using both x0n and joshua ewer's answers to come full circle with a code example, I hope that's not too bad form:
$url = 'http://google.com'
$req = [system.Net.WebRequest]::Create($url)
try {
$res = $req.GetResponse()
}
catch [System.Net.WebException] {
$res = $_.Exception.Response
}
$res.StatusCode
#OK
[int]$res.StatusCode
#200