Microsoft Office 365: How to Access Exchange Online via PowerShell

IT

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 https://ps.outlook.com/powershell/ -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. http://go.microsoft.com/fwlink/?LinkID=135170, Accessed April 2, 2014
Access Office 365 PowerShell. http://help.outlook.com/en-us/140/cc952755.aspx, Accessed April 3rd, 2014
Connect to Exchange Online Using Remote PowerShell. http://technet.microsoft.com/en-us/library/jj984289(v=exchg.150).aspx, Accessed April 3, 2014
EOP / Office 365: Connect and Use PowerShell. http://msexchangeguru.com/2014/02/03/eop-o365-connect-powershell/, Accessed April 3, 2014
Installing Windows PowerShell 3.0. http://technet.microsoft.com/en-us/library/jj205328.aspx, Accessed April 10, 2014

More About the Author

Ideen Jahanshahi

Solutions Architect
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 ...
The InterWorks Approach to Great Consulting: Part 2 At InterWorks, we pride ourselves on being unique and having a different take on work than other companies out there. A huge part of ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

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
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

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