Function Ping-WebServer { Param([string]$url) $request = [System.Net.WebRequest]::Create($url) $response = $request.GetResponse() If ($response.StatusCode -eq "OK") { $True } else { $False } } Ping-WebServer "http://www.scriptinganswers.com"