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

How to Connect to Exchange Online via PowerShell

Learn how to connect to Exchange Online PowerShell step by step — covering installation, Modern Authentication, MFA support, certificate-based auth for automation, and essential cmdlets for IT admins managing Microsoft 365.
Mar 18, 2026
8 min read read
Minimalist flat vector illustration showing PowerShell terminal and Exchange Online email server icons on dark navy background with gold accents

How to Connect to Exchange Online PowerShell: The Complete IT Admin Guide

If you manage Microsoft 365 for your organization, knowing how to connect to Exchange Online PowerShell is one of the most essential skills in your toolkit. Whether you're automating mailbox provisioning, running bulk configuration changes, or troubleshooting mail flow issues, the Exchange Online PowerShell module gives you capabilities that simply aren't available in the graphical admin center. In this guide, you'll learn exactly how to connect to Exchange Online PowerShell step by step — including prerequisites, installation, authentication methods, and the most useful commands to get started.

What Is Exchange Online PowerShell?

Exchange Online PowerShell is a command-line interface that allows IT administrators to manage Exchange Online — Microsoft's cloud-hosted email service — using PowerShell scripts and cmdlets. Unlike the Exchange admin center (EAC) web interface, PowerShell lets you automate repetitive tasks, manage large numbers of mailboxes simultaneously, access settings not exposed in the GUI, and build scripts that integrate with your broader IT workflows.

Microsoft has made significant updates to how you connect to Exchange Online PowerShell in recent years. The legacy Basic Authentication method has been deprecated in favor of Modern Authentication (OAuth 2.0), which is more secure and aligns with Microsoft's Zero Trust security model. The current recommended approach uses the ExchangeOnlineManagement PowerShell module, also known as EXO V3.

Who Needs Exchange Online PowerShell?

Exchange Online PowerShell is an essential tool for:

  • IT administrators managing Microsoft 365 tenants
  • Managed service providers (MSPs) supporting multiple client environments
  • System engineers automating email infrastructure tasks
  • Security teams running compliance and audit reports
  • Help desk staff who need to troubleshoot beyond the GUI

Prerequisites: What You Need Before Connecting

Before you can connect to Exchange Online PowerShell, make sure your environment meets the following requirements. Skipping this step is the most common reason admins run into errors during setup.

System Requirements

  • Operating System: Windows 10/11, Windows Server 2016 or later, macOS, or Linux
  • PowerShell Version: PowerShell 5.1 or PowerShell 7.x (7.x recommended for cross-platform use)
  • Internet Access: Your machine must be able to reach Microsoft's authentication endpoints
  • .NET Framework: .NET 4.7.2 or later on Windows

Account Requirements

  • A Microsoft 365 account with Exchange Online access
  • One of the following admin roles: Global Administrator, Exchange Administrator, or a custom role with the appropriate permissions
  • If using multi-factor authentication (MFA) — which Microsoft now requires for most tenants — your account must be MFA-enabled

Module Requirements

You need the ExchangeOnlineManagement module installed from the PowerShell Gallery. We'll cover this in the step-by-step guide below.

Step-by-Step Guide: Connecting to Exchange Online PowerShell

Follow these steps to install the Exchange Online PowerShell module and establish your first connection. These instructions apply to both Windows PowerShell 5.1 and PowerShell 7.x.

Step 1: Open PowerShell as Administrator

On Windows, right-click the Start menu and select Windows PowerShell (Admin) or Terminal (Admin). Running as administrator is required for module installation. On macOS or Linux, open your terminal — you may need to use sudo for the installation step.

Step 2: Set the PowerShell Execution Policy

If you're running this for the first time on a Windows machine, you may need to update the execution policy to allow script execution. Run the following command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. Choose RemoteSigned for the current user scope, which allows locally written scripts to run while requiring downloaded scripts to be signed.

Step 3: Install the ExchangeOnlineManagement Module

Install the Exchange Online PowerShell module from the PowerShell Gallery: Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber. The -Force flag skips the confirmation prompt, and -AllowClobber allows the installation to overwrite any conflicting commands. If you are updating from an older version, use: Update-Module -Name ExchangeOnlineManagement. To verify the module installed correctly, run: Get-Module -Name ExchangeOnlineManagement -ListAvailable

Step 4: Import the Module

Before connecting, import the module into your current PowerShell session: Import-Module ExchangeOnlineManagement. In newer versions of PowerShell, the module may auto-import when you call a cmdlet, but it's good practice to import it explicitly, especially in scripts.

Step 5: Connect to Exchange Online

This is the core command. Run the following to connect to Exchange Online PowerShell using Modern Authentication: Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com. Replace admin@yourdomain.com with your Microsoft 365 admin account. A browser window or in-terminal prompt will appear asking you to authenticate. If your account has MFA enabled, you'll complete your second factor here. Once authenticated, your session is established and you'll see confirmation in the PowerShell window.

Step 6: Verify Your Connection

Confirm you're connected by running a simple cmdlet: Get-EXOMailbox -ResultSize 5. This retrieves the first 5 mailboxes from your Exchange Online tenant. If you see results, your connection is working correctly.

Step 7: Disconnect When Finished

Always disconnect from Exchange Online when you're done to free up resources and maintain security hygiene: Disconnect-ExchangeOnline -Confirm:$false. The -Confirm:$false flag suppresses the confirmation prompt, making it useful in scripts.

Authentication Methods Compared

Your team may encounter different authentication scenarios depending on your organization's setup. Here is a comparison of the main methods:

MethodCommand ParameterMFA SupportBest ForStatus
Modern Auth (Interactive)-UserPrincipalNameYesAdmin workstationsRecommended
Certificate-Based Auth-CertificateThumbprintN/A (no password)Unattended scripts, automationRecommended
Managed Identity-ManagedIdentityN/AAzure Automation, Azure FunctionsRecommended
Basic Authentication-Credential (legacy)NoLegacy scriptsDeprecated — do not use

For automation scenarios where you need to connect without human interaction, certificate-based authentication is the gold standard. You register an Azure AD app registration, assign it Exchange permissions, and authenticate using a certificate thumbprint instead of a password.

Connecting Without Interactive Login: Certificate-Based Auth for Automation

If your team needs to run scheduled scripts or connect from Azure Automation, you'll need an approach that does not require interactive login. Here is how to set up certificate-based authentication.

  1. Create an Azure AD App Registration: In the Azure portal, go to Azure Active Directory, then App registrations, then New registration. Give it a descriptive name like ExchangeOnline-Automation and register it.
  2. Assign API Permissions: Under your app registration, go to API permissions, then Add a permission, then APIs my organization uses, then Office 365 Exchange Online. Add the application permission Exchange.ManageAsApp and grant admin consent.
  3. Create and Upload a Certificate: Generate a self-signed certificate or use your PKI infrastructure, then upload the public certificate to the app registration under Certificates and secrets.
  4. Assign Exchange Admin Role: The app registration's service principal needs an Exchange Online admin role. Go to Roles and administrators in Azure AD and assign the Exchange Administrator role to your app.
  5. Connect Using the Certificate: Use this command in your script: Connect-ExchangeOnline -AppId "your-app-id" -CertificateThumbprint "your-cert-thumbprint" -Organization "yourdomain.onmicrosoft.com"

Essential Exchange Online PowerShell Commands

Once you're connected, here are the most commonly used cmdlets your team will need on a day-to-day basis:

Mailbox Management

  • Get-EXOMailbox — Retrieve mailbox information. Use this instead of the older Get-Mailbox for better performance in Exchange Online.
  • Set-Mailbox -Identity user@domain.com -ProhibitSendQuota 10GB — Set mailbox size limits.
  • New-Mailbox -Name "John Smith" -UserPrincipalName jsmith@domain.com — Create a new mailbox.
  • Enable-Mailbox -Identity user@domain.com — Enable an existing user's mailbox.

Shared Mailbox Commands

  • New-Mailbox -Shared -Name "Support" -DisplayName "IT Support" -Alias support — Create a shared mailbox.
  • Add-MailboxPermission -Identity support@domain.com -User jsmith@domain.com -AccessRights FullAccess — Grant full access to a shared mailbox.
  • Get-EXOMailbox -RecipientTypeDetails SharedMailbox — List all shared mailboxes in your tenant.

Mail Flow and Reporting

  • Get-TransportRule — List all mail transport rules.
  • Get-MessageTrace -SenderAddress sender@domain.com -StartDate (Get-Date).AddDays(-7) — Trace email delivery over the past 7 days.
  • Get-EXOMailboxStatistics -Identity user@domain.com — View mailbox size and item count.
  • Get-AdminAuditLogConfig — Check audit logging configuration.

Troubleshooting Common Connection Errors

Even experienced admins run into issues when connecting to Exchange Online PowerShell. Here are the most common errors and how to resolve them quickly.

"The term Connect-ExchangeOnline is not recognized"

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

"Access is denied" or "Insufficient permissions"

Your account does not have the required Exchange Online admin role. Have your Global Administrator grant you the Exchange Administrator role in the Microsoft 365 admin center under Roles, then Role assignments.

Authentication fails with MFA accounts

Make sure you're using the modern Connect-ExchangeOnline -UserPrincipalName syntax and not the legacy -Credential parameter. The credential parameter does not support MFA and has been deprecated.

Connection timeout or the session hangs

Check that your network allows outbound HTTPS (port 443) to outlook.office365.com and login.microsoftonline.com. Corporate firewalls or proxy settings sometimes block these endpoints. Add them to your proxy bypass list or firewall allowlist if needed.

"WinRM client cannot process the request"

This is a legacy error from the old Remote PowerShell connection method. Update to the latest ExchangeOnlineManagement module using Update-Module -Name ExchangeOnlineManagement and you'll use REST-based connections that do not require WinRM.

Best Practices for Exchange Online PowerShell Administration

Following these best practices will keep your Exchange Online PowerShell usage secure, efficient, and auditable:

  • Use EXO V3 cmdlets: Cmdlets starting with Get-EXO such as Get-EXOMailbox use REST APIs and are significantly faster than legacy cmdlets for large environments.
  • Never store credentials in scripts: Use certificate-based authentication for automation, Azure Key Vault for secret management, or Windows Credential Manager. Hard-coded passwords are a serious security risk.
  • Apply least-privilege access: Connect with a dedicated service account with only the Exchange Administrator role — not Global Admin — for routine tasks.
  • Disconnect after every session: Always run Disconnect-ExchangeOnline at the end of your scripts to prevent session leaks and resource exhaustion.
  • Use -WhatIf for bulk changes: Adding -WhatIf to commands like Remove-Mailbox or Set-Mailbox shows you what would happen without making changes. Always test before running in production.
  • Log your sessions: Use PowerShell's Start-Transcript cmdlet to create a log of every command and its output for auditing and troubleshooting.
  • Test in a developer tenant: Microsoft provides free developer tenants through the Microsoft 365 Developer Program. Use these to test bulk changes safely before applying them in production.
  • Keep the module updated: Run Update-Module -Name ExchangeOnlineManagement periodically to get the latest cmdlets, bug fixes, and security improvements.

Frequently Asked Questions

Do I need to be a Global Administrator to connect to Exchange Online PowerShell?

No. The Exchange Administrator role is sufficient for most Exchange Online PowerShell tasks. For read-only access, the View-Only Organization Management or Global Reader roles may be enough. Microsoft recommends following least privilege and not using Global Admin accounts for routine Exchange management.

Can I connect to Exchange Online PowerShell on a Mac or Linux?

Yes. The ExchangeOnlineManagement module supports cross-platform use via PowerShell 7.x (PowerShell Core). Install PowerShell 7 from Microsoft's GitHub releases and follow the same steps as Windows. The interactive authentication window opens in your default browser.

What is the difference between Get-Mailbox and Get-EXOMailbox?

Get-EXOMailbox is the modern REST-based replacement for Get-Mailbox in Exchange Online environments. It is significantly faster when querying large numbers of mailboxes and returns a streamlined property set by default. Use Get-EXOMailbox for all new scripts targeting Exchange Online.

How do I connect to Exchange Online PowerShell without being prompted for credentials each time?

For scheduled tasks and automation, use certificate-based authentication as described above. This uses an Azure AD app registration with a certificate — no interactive login required. For interactive sessions, you'll still need to authenticate once per session, but you can use -ShowBanner:$false to skip the connection banner.

Is it safe to use Exchange Online PowerShell through a jump server?

Yes, provided the jump server has the ExchangeOnlineManagement module installed and meets all prerequisites. The connection authenticates through Microsoft's OAuth endpoints, not the jump server itself. Ensure your jump server has MFA enforced, is fully patched, and monitored. Using a dedicated privileged access workstation (PAW) is a best practice for this type of administrative access.

Ready to Simplify Your Microsoft 365 Administration?

Connecting to Exchange Online PowerShell is just the starting point. Your team can use it to automate mailbox provisioning, enforce compliance policies, streamline user offboarding, and build powerful integrations across your entire Microsoft 365 environment. But managing Exchange Online effectively — alongside Entra ID, Teams, SharePoint, Intune, and the rest of the Microsoft 365 stack — takes expertise, time, and constant attention.

At Always Beyond, we specialize in managed Microsoft 365 services for SMBs and growing organizations. Whether you need help with initial Exchange Online setup, ongoing administration, security hardening, or custom PowerShell automation, our certified team is ready to help your organization get the most from your Microsoft investment.

Contact Always Beyond today to learn how our managed IT services can take the complexity out of Microsoft 365 and free your team to focus on what matters most.

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