How to connect to Microsoft Exchange Online using PowerShell

Step 1:

The first thing you need to do is to install ExchangeOnlineManagement module for PowerShell.

Install-Module -Name ExchangeOnlineManagement -RequiredVersion 3.1.0

Installation logs..

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this 
repository, change its InstallationPolicy value by running the Set-PSRepository
 cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help 
(default is "N"):y
Installing package 'ExchangeOnlineManagement…

Step 2

Now let's connect to ExchangeOnlineManagement,


This shall open up the web browser and ask you to log in to your account.

Microsoft Exchange Online Login Page

Once you Authenticate (may require MFA if enabled) you will see this message.

Authentication complete. You can return to the application. Feel free to close this browser tab.

And you should get a message on the console.

This V3 EXO PowerShell module contains new REST API backed Exchange Online cmdlets which doesn't require WinRM for Client-Server communication. You can now run these cmdlets after turning off WinRM Basic Auth in your client machine thus making it more secure.

Unlike the EXO* prefixed cmdlets, the cmdlets in this module support full functional parity with the RPS (V1) cmdlets.

V3 cmdlets in the downloaded module are resilient to transient failures, handling retries and throttling errors inherently.

However, REST backed EOP and SCC cmdlets are not available yet. To use those, you will need to enable WinRM Basic Auth.

For more information check

Let's see if we are connected to ExchangeOnline,

PS /Users/c2ctechtv> Get-OrganizationConfig | Format-Table -Auto Name, ServicePlan, TenantGuid

Name                          ServicePlan       TenantGuid
----                          -----------       ---------- BPOS_S_E15_0_Slim 

If you want to disconnect with ExchangeOnline, run the below on the PowerShell Terminal.


Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap