Microsoft Office 365: How to Access Exchange Online via PowerShell


Microsoft Office 365: How to Access Exchange Online via PowerShell

After recently deploying a hybrid configuration for Office 365, many email settings that were easily configurable within Office 365 portal could not be changed as these settings were being managed by on-premise Active Directory servers. To get past this restriction, the next best option is to access the Exchange Online via PowerShell.  

Note: PowerShell 3.0 is required. For Windows Server 2012 or Windows Server 2012 R2, PowerShell does not need to be updated by default as PowerShell 3.0 is part of the operating system.

Access Exchange Online with PowerShell

First, tell PowerShell which credentials will be needed to connect to Exchange Online. For the prompt that will appear, you will need to connect using an Exchange Online administrator. If you are in an O365 Hybrid configuration, this could be a user that is on your domain or could be a stand-alone user with administrative privileges in Exchange Online.

Note: When opening up PowerShell, you will want to use the Run as Administrator command.

$LiveCred = Get-Credential

Step 1

Next, we will connect to Exchange Online.

$Session = New-PSSession – ConfigureationName Microsoft.Exchange –ConnectionUrl -Credential $LiveCred –Authentication Basic -AllowRedirection

Step 2 

By default, the execution policy will set to restricted. Changing this to allow commands to be ran from the PowerShell window requires us to allow commands to be remote-signed.

Set-ExecutionPolicy RemoteSigned

Step 3

Typically, after I am finished utilizing PowerShell, I will set the execution policy back to a restricted policy as these settings do not revert on closing PowerShell.

Set-ExecutionPolicy Restricted

Step 4

Sources Used:

About_Execution_Policies., Accessed April 2, 2014
Access Office 365 PowerShell., Accessed April 3rd, 2014
Connect to Exchange Online Using Remote PowerShell., Accessed April 3, 2014
EOP / Office 365: Connect and Use PowerShell., Accessed April 3, 2014
Installing Windows PowerShell 3.0., Accessed April 10, 2014

More About the Author

Ideen Jahanshahi

Solutions Architect
Veeam NAS Backup: Integrating with Dell EMC Isilon Those of us who have been in the backup realm a long time remember when Veeam Backup and Replication (Veeam B&R) was one of the top ...
The InterWorks Approach to Great Consulting: Part 3 If you’ve been following along, you know that this blog miniseries is all about dissecting the shared traits that some of my most ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK


Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Geschäftsführer: Mel Stephenson

Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072


Love our blog? You should see our emails. Sign up for our newsletter!