Back to blog

Connecting to Office 365 using PowerShell through a Web Proxy Server

Jun 13, 2013 by Emma Robinson

This is a follow up to blog post we previously wrote showing how to connect to Office 365 using PowerShell.

I recently came across a scenario where a company routed all traffic through a web proxy server – which is not uncommon at large organisations.

I had to make some modifications to my Office 365 connection strings and tell it to use the same settings as my Internet Explorer proxy settings.


First, I had to use the New-PSSessionOption cmdlet to save add the proxy information like this:

$proxysettings = New-PSSessionOption -ProxyAccessType IEConfig

I then had to pass the $proxysettings variable to the new session creation as follows:

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $cred -Authentication Basic -AllowRedirection -SessionOption $proxysettings

When you put it all together, it looks like this:

PS C:\Users\burns_000\Desktop> $proxysettings = New-PSSessionOption -ProxyAccessType IEConfig
PS C:\Users\burns_000\Desktop> $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $cred -Authentication Basic -AllowRedirection -SessionOption $proxysettings
WARNING: Your connection has been redirected to the following URI:
" "

PS C:\Users\burns_000\Desktop> Import-PSSession $session
PS C:\Users\burns_000\Desktop>


Take the next step towards advanced SaaS management with our Office 365 reporting software.