title: How to show TLS handshake information and CONNECT request in Invoke-WebRequest
body: <p>When I'm accessing a site through HTTPS and/or with HTTP proxy, cURL in Linux provides the <code>-v</code>/<code>--verbose</code> flag to show the <code>CONNECT</code> request to the proxy, as well as the SSL/TLS handshake process (including certificate), like</p>
  
  <pre class="lang-none prettyprint-override"><code>* Rebuilt URL to: https://www.example.com/
  *   Trying 192.168.2.1...
  * Connected to my-proxy.local (192.168.2.1) port 8080 (#0)
  * Establish HTTP proxy tunnel to www.example.com:443
  &gt; CONNECT www.example.com:443 HTTP/1.1
  &gt; Host: www.example.com:443
  &gt; User-Agent: curl/7.47.0
  &gt; Proxy-Connection: Keep-Alive
  &gt;
  &lt; HTTP/1.1 200 Connection established
  &lt;
  * Proxy replied OK to CONNECT request
  * found 148 certificates in /etc/ssl/certs/ca-certificates.crt
  * found 597 certificates in /etc/ssl/certs
  * ALPN, offering http/1.1
  * SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
  *        server certificate verification OK
  *        server certificate status verification SKIPPED
  *        common name: www.example.org (matched)
  *        server certificate expiration date OK
  *        server certificate activation date OK
  *        certificate public key: RSA
  *        certificate version: #3
  *        subject: C=US,ST=California,L=Los Angeles,O=Internet Corporation for Assigned Names and Numbers,OU=Technology,CN=www.example.org
  *        start date: Tue, 03 Nov 2015 00:00:00 GMT
  *        expire date: Wed, 28 Nov 2018 12:00:00 GMT
  *        issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2 High Assurance Server CA
  *        compression: NULL
  * ALPN, server accepted to use http/1.1
  &gt; GET / HTTP/1.1
  &gt; Host: www.example.com
  &gt; User-Agent: curl/7.47.0
  &gt; Accept: */*
  &gt;
  &lt; HTTP/1.1 200 OK
  &lt; Cache-Control: max-age=604800
  &lt; Content-Type: text/html
  &lt; Date: Mon, 27 Nov 2017 23:08:55 GMT
  &lt; Etag: "359670651+gzip+ident"
  &lt; Expires: Mon, 04 Dec 2017 23:08:55 GMT
  &lt; Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
  &lt; Server: ECS (ord/4C84)
  &lt; Vary: Accept-Encoding
  &lt; X-Cache: HIT
  &lt; Content-Length: 1270
  &lt;
  &lt; (body...)
  </code></pre>
  
  <p>Is there anyway to get similar information when using <code>Invoke-WebRequest</code>? Or should I use another CmdLet? I tried <code>-Debug</code> and <code>-Verbose</code>, both of which shows neither information. Even the raw content only contains the actual request after proxy, that is, in the above example the <code>GET / HTTP/1.1</code>.</p>
  
  <p>In brief, I want to see something like the line</p>
  
  <pre class="lang-none prettyprint-override"><code>&gt; CONNECT www.example.com:443 HTTP/1.1
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-none prettyprint-override"><code>* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
  </code></pre>