How to connect to Exchange Online using PowerShell in Office 365

Hi Everyone this is Prem, I have worked as Microsoft 365 support ambassador. In this blog I will share how to connect with Exchange online using PowerShell in Office 365.

Steps to connect to Exchange online using PowerShell:

Search for windows PowerShell on your computer and run it as an administrator:

Once opened it should look like this:


Now connect to Exchange online using the PowerShell which is opened, to connect to exchange online run the following command:


Install-Module -Name ExchangeOnlineManagement


Allow permission to install if asked. After that run:

Import-Module -Name ExchangeOnlineManagement


If you get error that running script is disabled  or other error when running the first Install command then run the following command and after this run the above  Install and Import commands again:

Set-ExecutionPolicy unrestricted -scope currentuser

Allow it to set the execution policy if prompted by entering A or Y.

Install-Module -Name ExchangeOnlineManagement 

Import-Module -Name ExchangeOnlineManagement


After that run:


Enter your Global or Exchange Admin email address and password and it should get connected to Exchange Online on the PowerShell:

If you have Multifactor Authentication enabled on the account then you will have to complete the second steps of Authentication (Text, Call, Authenticator app, etc.) as well and after it is completed you should be connected to Exchange Online using PowerShell.

By following the above steps you should be able to connect to exchange online using PowerShell.


Author: Prem

Tags: How to connect to Exchange Online using PowerShell in Office 365

Leave a Comment