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.

 

To connect to Exchange Online using Windows PowerShell, we will first have to make sure the necessary module is installed on the PowerShell.

 

ExchangeOnlineManagement is the Module which is required, it stores all the commands of Exchange Online to be able to run on PowerShell.

 

If you have already installed ExchangeOnlineManagement module, then you can directly run the Connect-ExchangeOnline command in the PowerShell to Connect to Exchange Online.

 

Irrespective of whether you have it installed or not, you can follow all the steps shown to successfully connect to Exchange Online. 

 

If script running is disabled on you computer then we can enable it on user account level, that will allow us to Install and connect to Exchange Online.

 

Steps to connect to Exchange online using PowerShell:

 

Search for windows PowerShell on your computer locally, and run it As an Administrator:

 

connect to Exchange Online using PowerShell

 

Once opened it should look like this:

 

 connect to Exchange Online using PowerShell in Office 365

 

 

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

 

 

Set-ExecutionPolicy RemoteSigned -Scope Currentuser

 

connect to Exchange Online using PowerShell

 

 

Allow it to set the execution policy if prompted by entering A. Then run:

 

 

Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser

 

 

connect to Exchange Online using PowerShell

 

Allow permission to install it by entering Y. After that run:

 

 

Import-Module -Name ExchangeOnlineManagement

 

 

connect

 

After that run:

 

 

Connect-ExchangeOnline

 

connect to Exchange Online using PowerShell

 

 

 

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

 

 

connect to Exchange Online using 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.

 

 

Once you are connected you should be able to Run Exchange online Commands in the Powershell, for Example:

 

 

Get-Mailbox

 

get-mailbox

 

 

Date:1/08/2022

 

Author: Prem

 

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

Leave a Comment

Your email address will not be published. Required fields are marked *