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-factorauthentication

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.

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

Install-Module –NameExchangeOnlineManagement

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

Get-Module -Name ExchangeOnlineManagement -ListAvailable

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

Import-ModuleExchangeOnlineManagement

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

Connect to Exchange Online PowerShell:

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

Connect-ExchangeOnline

It will prompt for theuser’sname 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
 }
 else
 {
  Write-Host EXO V3 module is required to connect Exchange Online. Please install module using Install-Module ExchangeOnlineManagement cmdlet.
  Exit
 }
}
Write-Host Connecting to Exchange Online...
Connect-ExchangeOnline

Common Errors and Troubleshooting Tips:

1. Set the execution policy to Remote Signed

Windows PowerShell needstobeconfigured to runtheremote scriptand it is not enabled by default. If you haven’tenabledit, you will getthebelow 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-ExecutionPolicyRemoteSigned

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

When trying to connect Exchange Online usingthe‘Connect-ExchangeOnline” cmdlet, you will getthefollowing 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 ofthe name, or if a path was included, verify thatthe path is correct andtry again.

Solution:To usetheConnect-ExchangeOnlinecmdlet, you must install and importtheExchangeOnlineManagementmodule.

3. Disconnect Exchange Online PowerShell session

Make sure todisconnect the remote PowerShell sessionwhen you’re finished.Else you ended up using all remote PowerShell sessions available to you and you willget the following error.

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

Solution: DisconnectthePowerShell sessionusingbelow command.

Disconnect-ExchangeOnline–Confirm:$false

The above syntax, disconnectstheExchange Online sessions withoutthe 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 atthe client-side. IfWinRMbasicauthenticationisdisabled, youwill get the error.

New-ExoPSSession:Connecting to remote server outlook.office365.com failed with the following errormessage:TheWinRMclient cannot process the request. Basicauthentication iscurrently disabledinthe client configuration.

Solution: To enableWinRMbasic auth, run thebelow cmdlet inthecommand prompt.

winrmsetwinrm/config/client/auth @{Basic="true"}

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

Finally, we havedone with connecting to EXO PowerShell. Despite all the advantages of PowerShell, admins often rely on third-party solutions due to several factors, including the mess around the output, multiple scripts, and more, where PowerShell falls short. AdminDroid is an elite tool in the Exchange Online reporting and auditing world. Let’s dive into its numerous features and reports.

How AdminDroid Outshines🌟 among NativeExchange Online ManagementTools?

AdminDroid delivers crystal-clear detailsand AI-generated powerful charts thatfulfill all the reporting & auditing requirements whichadmins ever crave for. In addition, the Exchange Online dashboard lets you have a glimpse of your EXO environment, such as mailbox audit, mailbox connections, and mailbox usage,with appealing insights.

Exchange Online Dashboard

With the AdminDroid Exchange Online reporting tool, you will get details on mailbox usage, mailbox settings, mailbox devices, and more.

Additionally, it makes your Exchange Online auditing a cakewalk by providing reports on mailbox accesses, mailbox permission changes, ATP, Exchange configuration changes, etc.

Furthermore, AdminDroid has several amazing yet useful features like alerting, granular delegation, compliance reporting, advanced schedule, advanced filters, and the list never ends. Undoubtedly, AdminDroid is a gem💎 in enhancing your Exchange Online managementand securing your mailboxes efficiently.

Don’t confine yourself tomailbox management in the oceanof AdminDroid. In addition, it empowers you by providing control over your mailbox traffic, email statistics, threat protection details, users’ peak & slack hours, and the list goes on. Reap the benefit of the AdminDroid email monitoring tool and maximize your email management & security.Explore AdminDroid today and enjoy the plethora of Microsoft 365 reports and features!

Connect to Exchange Online PowerShell 

by Kathy time to read: 4 min
0