title: Check url status in PowerShell version 2
body: <p>I have the below code to check website status in PowerShell version 2.</p>
  
  <pre><code>Begin {
      $webRequest = [Net.WebRequest]::Create("http://webdesa2:2003/Login.aspx");
  }
  Process {
      try {
          if ((($webRequest.GetResponse()).Statuscode) -as [int] -eq 200) {
              Write-Host "Site is Up";
              $webrequest.GetResponse();
          } else {
              Write-Host -Fore Red "Site is Down"
          }
      } catch {
          Write-Host -Fore Red "Site is Down"
      }
  }
  </code></pre>
  
  <p>But I am getting the below output when executing the above code.</p>
  
  <blockquote>
    <p>Exception calling "GetResponse" with "0" arguments: "The remote server returned an error: &lt;401> Unauthorized."</p>
  </blockquote>
  
  <p>This code worked good on websites where authentication is not required. My intention is to check if the site is up or not.</p>