Always Beyond Team
Managed IT Services

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.
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.
Exchange Online PowerShell is an essential tool for:
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.
You need the ExchangeOnlineManagement module installed from the PowerShell Gallery. We'll cover this in the step-by-step guide below.
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.
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.
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.
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
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.
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.
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.
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.
Your team may encounter different authentication scenarios depending on your organization's setup. Here is a comparison of the main methods:
| Method | Command Parameter | MFA Support | Best For | Status |
|---|---|---|---|---|
| Modern Auth (Interactive) | -UserPrincipalName | Yes | Admin workstations | Recommended |
| Certificate-Based Auth | -CertificateThumbprint | N/A (no password) | Unattended scripts, automation | Recommended |
| Managed Identity | -ManagedIdentity | N/A | Azure Automation, Azure Functions | Recommended |
| Basic Authentication | -Credential (legacy) | No | Legacy scripts | Deprecated — 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.
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.
Once you're connected, here are the most commonly used cmdlets your team will need on a day-to-day basis:
Even experienced admins run into issues when connecting to Exchange Online PowerShell. Here are the most common errors and how to resolve them quickly.
This means the module is not installed or not imported. Run Install-Module -Name ExchangeOnlineManagement -Force followed by Import-Module ExchangeOnlineManagement and try again.
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.
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.
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.
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.
Following these best practices will keep your Exchange Online PowerShell usage secure, efficient, and auditable:
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.
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.
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.
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.
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.
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.
See exactly how your current IT setup measures up to our Hack Free standards. Enter your business email to receive: