Want to learn more?
Complete guide to Windows Update command-line tools for IT administrators.
Read the guideDevOps & Development Experts
From CI/CD pipelines to custom applications, our team builds secure solutions that scale.
What Is Exchange Online PowerShell
Exchange Online PowerShell provides administrative command-line access to Microsoft Exchange Online, the cloud-based email and calendaring service in Microsoft 365. While the Exchange Admin Center (EAC) provides a web-based GUI, PowerShell enables bulk operations, automation, and access to advanced settings not available in the portal.
Exchange Online PowerShell is essential for managing mailboxes, distribution groups, mail flow rules, retention policies, and compliance features at enterprise scale. Operations that would require hours of clicking in the admin portal can be completed in seconds with the right PowerShell commands.
Common Command Categories
| Category | Example Commands | Purpose |
|---|---|---|
| Mailbox Management | Get-Mailbox, Set-Mailbox, New-Mailbox | Create, configure, and query mailboxes |
| Distribution Groups | Get-DistributionGroup, Add-DistributionGroupMember | Manage email groups and membership |
| Mail Flow Rules | Get-TransportRule, New-TransportRule | Configure mail routing and filtering rules |
| Permissions | Add-MailboxPermission, Get-MailboxFolderPermission | Manage mailbox delegation and folder access |
| Compliance | Get-RetentionPolicy, New-ComplianceSearch | Configure retention, eDiscovery, and audit policies |
| Anti-Spam | Get-HostedContentFilterPolicy | Manage spam filtering and quarantine settings |
| Mobile Devices | Get-MobileDeviceStatistics | Manage ActiveSync and mobile device policies |
Common Use Cases
- Bulk mailbox operations: Set out-of-office messages, change mailbox quotas, or update properties for hundreds of mailboxes using CSV imports
- Shared mailbox management: Create shared mailboxes, assign full access and send-as permissions, and configure auto-mapping for delegate access
- Mail flow troubleshooting: Trace message delivery paths, review transport rules, and diagnose delivery failures
- Compliance configuration: Set up retention policies, litigation holds, and eDiscovery searches for legal and regulatory requirements
- Migration assistance: Export mailbox statistics, identify large mailboxes, and prepare user lists for migrations between Exchange environments
Best Practices
- Use the EXO V3 module — Connect using
Connect-ExchangeOnlinefrom the ExchangeOnlineManagement module (v3+). This supports modern authentication, certificate-based auth, and REST-based cmdlets. - Limit result sets — Use
-ResultSizeto limit query results. Querying all mailboxes in a large tenant without limits can timeout or consume excessive resources. - Use -WhatIf for destructive operations — Before running Set- or Remove- commands on multiple objects, add
-WhatIfto preview what would change without making actual modifications. - Implement error handling in scripts — Wrap bulk operations in try/catch blocks and log failures. A single failed mailbox operation should not halt processing of the remaining batch.
- Disconnect sessions when finished — Always run
Disconnect-ExchangeOnlinewhen done. Exchange Online limits the number of concurrent PowerShell sessions per tenant.
Frequently Asked Questions
Common questions about the Exchange Online PowerShell Generator
First install the Exchange Online PowerShell module: Install-Module -Name ExchangeOnlineManagement. Then connect using: Connect-ExchangeOnline -UserPrincipalName [email protected]. You will be prompted for authentication, which supports MFA.