Connect to Exchange Online PowerShell 

Connect to Exchange Online PowerShell 

Exchange Online PowerShell helps administrators to manage their Exchange Online Environment more effectively. EXO V3 module allows admins to create remote PowerShell sessions by using both 

  • Modern authentication 
  • Multi-factor authentication 

Let’s see how to install and connect Exchange Online PowerShell using the EXO V3 module. 

Install Exchange Online PowerShell Module: 

To install EXO V3 module, follow the below steps. 

Step 1: Start Windows PowerShell with the “Run as administrator” option.  

Step 2: Run the below cmdlet to install the Exchange Online PowerShell V3 Module (ExchangeOnlineManagement)  

Install-Module –Name ExchangeOnlineManagement 

Note: To identify the installed EXO V3 module’s version, run the below cmdlet. 

Get-Module Name ExchangeOnlineManagement -ListAvailable 

Step 3: After installing the EXO V3 module, import the EXO V3 module cmdlets by running the following cmdlet. 

Import-Module ExchangeOnlineManagement 

EXO V3 module supports REST API-based cmdlets like Get-EXOMailbox, Get-EXOMailboxStatistics, etc. 


Connect to Exchange Online PowerShell: 

You can use the Connect-ExchangeOnline cmdlet to create a PowerShell session to Exchange Online. Both MFA and non-MFA accounts can be connected using the below cmdlet. 


It will prompt for the user’s name and password. After entering the credential, it will create an Exchange Online PowerShell session. 


Automatically Install and Connect to Exchange Online PowerShell: 

To automatically install the EXO V3 module and connect to Exchange Online PowerShell, you can use the below PowerShell script. 

#Check for EXO v3 module installation
$Module = | (Get-Module ExchangeOnlineManagement -ListAvailable) | where {$_.Version.major -ge 3}
if($Module.count -eq 0)
 Write-Host Exchange Online PowerShell V3 module is not available -ForegroundColor yellow
 $Confirm= Read-Host Are you sure you want to install module? [Y] Yes [N] No
 if($Confirm -match "[yY]")
  Write-host "Installing Exchange Online PowerShell module"
  Install-Module ExchangeOnlineManagement -Repository PSGallery -AllowClobber -Force
  Import-Module ExchangeOnlineManagement
  Write-Host EXO V3 module is required to connect Exchange Online. Please install module using Install-Module ExchangeOnlineManagement cmdlet.
Write-Host Connecting to Exchange Online...


Common Errors and Troubleshooting Tips: 

1. Set the execution policy to Remote Signed 

Windows PowerShell needs to be configured to run the remote script and it is not enabled by default. If you haven’t enabled it, you will get the below error. 

Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files. 

Solution: Run the following cmdlet. 

Set-ExecutionPolicy RemoteSigned 


2. ‘Connect-ExchangeOnline‘ is not recognized as the name of a cmdlet: 

When trying to connect Exchange Online using the ‘Connect-ExchangeOnline” cmdlet, you will get the following error. 

Connect-ExchangeOnline : The term ‘Connect-ExchangeOnline’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 

Solution: To use the Connect-ExchangeOnline cmdlet, you must install and import the ExchangeOnlineManagement module. 


3. Disconnect Exchange Online PowerShell session 

Make sure to disconnect the remote PowerShell session when you’re finished. Else you ended up using all remote PowerShell sessions available to you and you will get the following error. 

New-ExoPSSession : Processing data from remote server outlook.office365. com failed with the following error message: [AuthZRequestId=068a9813-8420-43f0-9f20-692228962287] [FailureCategory=AuthZ-AuthorizationException] Fail to create a runspace because you have exceeded the maximum number of connections allowed: 10 

Solution: Disconnect the PowerShell session using below command. 

Disconnect-ExchangeOnline –Confirm:$false 

The above syntax, disconnects the Exchange Online sessions without the prompt. 


4. Enable Basic Authentication on the WinRM service: 

EXO V2 module supports modern authentication in Office 365 end. However, it requires basic auth to transport modern auth tokens at the client-side. If WinRM basic authentication is disabled, you will get the error. 

New-ExoPSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Basic authentication is currently disabled in the client configuration. 

Solution: To enable WinRM basic auth, run the below cmdlet in the command prompt. 

winrm set winrm/config/client/auth @{Basic="true"} 

Note: EXO V3 module doesn’t require enabling WinRM basic auth.

Connect to Exchange Online PowerShell 

by Kathy time to read: 3 min