title: Invoke-WebRequest GetSystemWebProxy()
body: <p>Under PowerShell 2.0 I know that you can set the proxy you would like to use without knowing the exact proxy settings by doing something like the following:</p>
  
  <pre><code>$proxy = [System.Net.WebRequest]::GetSystemWebproxy()
  $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
  </code></pre>
  
  <p>Now, my question is if I don't know the proxy settings can I use the above and combine it with a PowerShell 3.0 <code>Invoke-WebRequest</code>. Here's what I was hoping to be able to do:</p>
  
  <pre><code>$proxy = [System.Net.WebRequest]::GetSystemWebproxy()
  $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
  
  $WS.Proxy = $proxy
  
  $login = Invoke-WebRequest https://website.com/login_form.html -SessionVariable WS
  </code></pre>
  
  <p>However, when I attempt to do this I get an error, (apparently from my company proxy) indicating that my credentials cannot be verified. I'm hoping that this will ultimately work, but perhaps I'm just making a simple mistake.</p>