title: Error Handling in System.Net.HttpWebRequest::GetResponse()
body: <p>I have a Powershell script that uses <code>System.Net.HttpWebRequest</code> to communicate with a remote host. </p>
  
  <p>I create the request, set properties accordingly and call <code>getresponse()</code> and <code>getresponsestream()</code> to read the entire response from the server to a string.  This works fine as long as the server responds with a "200 OK" message. </p>
  
  <p>If the server responds with a "400 Bad Request" or any other error code, <code>getresponse()</code> and <code>getresponsestream()</code> throw exceptions and return nothing. My problem is there is more detailed error information included in the response header which I need so I can do my own error handling. </p>
  
  <p>How would I be able to retrieve this 400 Bad Request signal?</p>