Always Beyond White Icon Logo Small
Is Your Business Secure?
Take our FREE 2-minute IT Security Scorecard and get instant insights—no strings attached.
👉 Start Assessment
Insights & Guides
Everyday Tech Tips

Connect to Exchange Online PowerShell

Learn how to connect to Exchange Online PowerShell using the EXO V3 module with modern authentication. Step-by-step guide for IT admins managing Microsoft 365.
Mar 19, 2026
8 min read read
Flat vector illustration of Exchange Online PowerShell connection with Microsoft 365 icons on dark navy background

How to Connect to Exchange Online PowerShell: The Complete Guide

If you manage Microsoft 365 for your organization, knowing how to connect to Exchange Online PowerShell is one of the most valuable skills in your IT toolkit. Whether you need to bulk-manage mailboxes, configure mail flow rules, troubleshoot delivery issues, or automate repetitive tasks, PowerShell gives you capabilities that the Exchange admin center simply cannot match. This guide walks you through everything you need to know — from prerequisites to advanced connection scenarios — so your team can start managing Exchange Online like pros.

What Is Exchange Online PowerShell?

Exchange Online PowerShell is a command-line interface that allows administrators to manage Exchange Online, the cloud-hosted email service included in Microsoft 365 (formerly Office 365). Unlike the graphical Exchange admin center (EAC), PowerShell lets you automate bulk operations, write scripts for recurring tasks, access settings not exposed in the GUI, and build integrations with other systems.

When you connect to Exchange Online PowerShell, you are establishing a remote PowerShell session directly to Microsoft's Exchange Online infrastructure. This gives your team granular control over every aspect of your email environment — mailboxes, distribution groups, mail flow rules, anti-spam policies, and much more.

Exchange Online PowerShell vs. Classic Remote PowerShell

Microsoft has been transitioning administrators from the legacy basic authentication (basic auth) remote PowerShell connection method to the newer, more secure Exchange Online PowerShell V3 module (EXO V3). The V3 module uses modern authentication (OAuth 2.0 / MFA support) and is now the only officially supported method. Basic authentication was deprecated by Microsoft in late 2022.

FeatureLegacy Remote PowerShellEXO V3 Module
AuthenticationBasic auth (username/password)Modern auth (OAuth 2.0 / MFA)
MFA SupportNoYes
REST API BackendNoYes (faster cmdlets)
Certificate AuthNoYes
App-only / UnattendedLimitedFull support
Current Support StatusDeprecatedActive / Recommended

Prerequisites: What You Need Before You Connect

Before your team attempts to connect to Exchange Online PowerShell, make sure the following requirements are in place.

  • Windows PowerShell 5.1 or PowerShell 7+: The EXO V3 module supports both, though PowerShell 7 is recommended for the best performance.
  • Exchange Online license: Your Microsoft 365 account must have an Exchange Online mailbox or be assigned an appropriate administrative role.
  • Admin role: You need at minimum the Exchange Administrator role, or Global Administrator in Azure Active Directory (Microsoft Entra ID).
  • Internet connectivity: Your machine needs outbound access to Microsoft 365 endpoints (*.outlook.com, *.protection.outlook.com).
  • ExchangeOnlineManagement module: This PowerShell module must be installed from the PowerShell Gallery.

Step-by-Step: How to Connect to Exchange Online PowerShell

Step 1: Install the ExchangeOnlineManagement Module

Open PowerShell as an administrator and run the following command to install the latest version of the EXO V3 module from the PowerShell Gallery:

Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber

If the module is already installed and you want to update to the latest version, run:

Update-Module -Name ExchangeOnlineManagement

To verify the installed version, use:

Get-Module ExchangeOnlineManagement -ListAvailable | Select-Object Name, Version

Step 2: Import the Module

Once installed, import the module into your current PowerShell session:

Import-Module ExchangeOnlineManagement

In most cases PowerShell will auto-import modules from the Gallery, but explicitly importing ensures you are using the correct version.

Step 3: Connect Using Interactive Modern Authentication

The standard interactive connection command is:

Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com

Replace admin@yourdomain.com with your Microsoft 365 admin account UPN. A browser window or in-app prompt will appear asking you to sign in with your credentials and complete MFA if required. Once authenticated, your PowerShell session will be connected to Exchange Online and you can begin running cmdlets.

Step 4: Verify Your Connection

After connecting, verify the session is active and working by running a simple test cmdlet:

Get-Mailbox -ResultSize 5

This should return up to five mailboxes from your Exchange Online environment. If you see results, your connection is successful.

Step 5: Run Your Administrative Commands

You are now connected and ready to manage your Exchange Online environment. Common tasks include listing all mailboxes, managing distribution groups, setting mailbox permissions, configuring mail flow rules, and much more — all from the command line.

Step 6: Disconnect When Done

When you finish your administrative work, always disconnect your session to free resources and maintain security hygiene:

Disconnect-ExchangeOnline -Confirm:$false

Connecting Without Prompts: Unattended and Automated Scenarios

For scripts that run on a schedule — such as nightly reports or automated mailbox provisioning — interactive login is not practical. The EXO V3 module supports two primary methods for unattended connections.

Option A: App-Only Authentication with a Certificate

This is the recommended approach for automation. You register an Azure AD application, assign it Exchange Online permissions (using application permissions, not delegated), and authenticate using a certificate rather than user credentials. The connection command looks like this:

Connect-ExchangeOnline -AppId "your-app-id" -CertificateThumbprint "your-cert-thumbprint" -Organization "yourdomain.onmicrosoft.com"

Option B: Managed Identity (Azure Automation / Azure Functions)

If your scripts run inside Azure Automation or Azure Functions with a managed identity, you can leverage the managed identity for certificate-based authentication without storing credentials anywhere.

Connecting from Non-Windows Systems

The ExchangeOnlineManagement module fully supports PowerShell 7 on macOS and Linux. The installation and connection process is identical — install the module via Install-Module, then use Connect-ExchangeOnline. This is particularly useful for DevOps teams and administrators who prefer cross-platform tooling.

Best Practices for Using Exchange Online PowerShell

  • Always use the latest EXO V3 module: Microsoft continuously updates the module with performance improvements and bug fixes. Keep it current with Update-Module -Name ExchangeOnlineManagement.
  • Use MFA-enabled accounts for interactive sessions: Never disable MFA for accounts used in interactive PowerShell sessions. Modern auth in EXO V3 supports MFA natively.
  • Use dedicated service accounts for automation: For unattended scripts, use a dedicated service principal (Azure AD app registration) rather than a real user account.
  • Limit permissions to what is needed: Apply the principle of least privilege. If your script only reads mailbox data, assign the View-Only Mailbox role rather than full Exchange Administrator.
  • Store credentials securely: Never hard-code passwords or tokens in scripts. Use Azure Key Vault, Windows Credential Manager, or environment variables.
  • Test in a non-production environment first: Before running bulk operations against all mailboxes, test your script against a small subset using the -ResultSize or Where-Object filter.
  • Log your sessions: Enable PowerShell transcript logging or use Start-Transcript so you have a record of commands run during each session.
  • Disconnect after each session: Always run Disconnect-ExchangeOnline when your work is done. Leaving sessions open can cause resource issues and represents a security risk.

Common Connection Errors and How to Fix Them

Error: "The term Connect-ExchangeOnline is not recognized"

This means the ExchangeOnlineManagement module is not installed or not imported. Run Install-Module -Name ExchangeOnlineManagement followed by Import-Module ExchangeOnlineManagement.

Error: "Access is denied" or "Insufficient permissions"

Your account does not have the required Exchange Online administrator role. Work with your Global Administrator to assign the Exchange Administrator or appropriate role in the Microsoft 365 admin center.

Error: "AADSTS50076: Due to a configuration change made by your administrator…"

This is an MFA-related error. Ensure you are using an account that can complete MFA, and that your Conditional Access policies allow PowerShell access from your current location or device.

Error: "Connect-ExchangeOnline: A connection to Exchange Online already exists"

You have an existing session open. Run Disconnect-ExchangeOnline -Confirm:$false first, then reconnect.

Frequently Asked Questions

Do I need to install anything special to use Exchange Online PowerShell?

Yes. You need to install the ExchangeOnlineManagement module from the PowerShell Gallery using Install-Module -Name ExchangeOnlineManagement. Beyond that, you need PowerShell 5.1 or later and a Microsoft 365 account with appropriate admin permissions. No additional software or Exchange server is required — everything runs through the cloud.

Can I connect to Exchange Online PowerShell with MFA enabled on my account?

Absolutely. The EXO V3 module (ExchangeOnlineManagement) was specifically designed to support modern authentication, which includes multi-factor authentication. When you run Connect-ExchangeOnline, a browser prompt or in-app authenticator request will appear for you to complete your MFA challenge. This is the recommended and most secure way to connect interactively.

How do I run Exchange Online PowerShell scripts without being prompted for credentials?

For unattended or automated scripts, you should use app-only authentication. Register an application in Azure Active Directory (Microsoft Entra ID), grant it the appropriate Exchange Online application permissions, create a certificate, and use the -AppId and -CertificateThumbprint parameters with Connect-ExchangeOnline. This allows your scripts to authenticate automatically without any interactive prompt.

Is Exchange Online PowerShell the same as on-premises Exchange Management Shell?

No, they are different tools. The on-premises Exchange Management Shell (EMS) is used to manage Exchange Server installed in your own data center. Exchange Online PowerShell connects to Microsoft's cloud-hosted Exchange Online service. While many cmdlet names are similar, their parameters and available options differ. You cannot use the on-premises EMS to manage Exchange Online, and vice versa.

How do I know which version of the ExchangeOnlineManagement module I have installed?

Run the command Get-Module ExchangeOnlineManagement -ListAvailable | Select-Object Name, Version in PowerShell to see the installed version. You can also check with Get-InstalledModule -Name ExchangeOnlineManagement. Compare the output against the latest version on the PowerShell Gallery (gallery.powershellgallery.com/packages/ExchangeOnlineManagement) to see if an update is available. Always keep the module current to benefit from the latest performance improvements and security fixes.

Take Your Exchange Online Management to the Next Level

Knowing how to connect to Exchange Online PowerShell is just the beginning. Once your team is comfortable with the basics, you can automate mailbox provisioning, build compliance reporting, manage mail flow at scale, and integrate Exchange Online administration into your broader IT operations workflows. The efficiency gains are significant — tasks that would take hours in the GUI can run in seconds through a well-crafted script.

At Always Beyond, we help organizations get the most out of their Microsoft 365 investment. Whether you need help setting up Exchange Online automation, tightening your email security posture, or building managed IT operations that scale — our team is ready to help. Get in touch with Always Beyond today and let's build an IT environment that works as hard as you do.

On this page

Ready to Make IT One Less Thing to Worry About?

Book a no-pressure consultation to see how Always Beyond can help you simplify, secure, and future-proof your IT.

See exactly how your current IT setup measures up to our Hack Free standards. Enter your business email to receive:

  • Free 10-point security scorecard for your business
  • Complete Hack Free Guarantee eligibility checklist
  • Exclusive case studies from our protected clients