title: Proxy setting for powershell connecting to outlook.office365
body: <p>I'm working on PowerShell script that connect to outlook office365(exchange online) as follows:</p>
  <pre><code>$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri &quot;https://outlook.office365.com/powershell-liveid/&quot; -Credential $credential -Authentication Basic -AllowRedirection
  </code></pre>
  <p>Now the problem is I want to connect via a proxy server with authentication, so did the following</p>
  <pre><code>$proxy = New-Object System.Net.WebProxy &quot;http://myproxy:80&quot;
  $proxy.Credentials = $cred
  [System.Net.WebRequest]::DefaultWebProxy = $proxy
  $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri &quot;https://outlook.office365.com/powershell-liveid/&quot; -Credential 
  $credential -Authentication Basic -AllowRedirection
  </code></pre>
  <p>But it doesn't connect via proxy that I set. So I did the following:</p>
  <pre><code>$proxy = New-Object System.Net.WebProxy &quot;http://myproxy:80&quot;
  $proxy.Credentials = $cred
  [System.Net.WebRequest]::DefaultWebProxy = $proxy
  $sessionOption = New-PSSessionOption -ProxyAccessType IEConfig
  $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri &quot;https://outlook.office365.com/powershell-liveid/&quot; -Credential 
  $credential -Authentication Basic -AllowRedirection -SessionOption $sessionOption
  </code></pre>
  <p>But still doesn't pass through proxy.</p>
  <p>I also tried to use <code>netsh winhttp set proxy &quot;myproxy:80&quot;</code> and it passed through the proxy server but it seems it doesn't have authentication.</p>
  <p>Is there any way to explicitly set the proxy for New-PSSession cmdlet?
  Note: I don't want to set proxy setting on IE, just want to explicitly set proxy per session.</p>