Generate correct Exchange Online PowerShell commands for mailbox permissions, forwarding audits, message trace, groups, calendars and reports.
This tool builds ready-to-run Exchange Online PowerShell commands from a form. Pick a task — grant Full Access to a shared mailbox, audit tenant-wide mail forwarding, run a message trace, create a distribution group, report on mailbox sizes — fill in the mailbox address or username, and the correct cmdlet syntax is generated with the connection preamble already attached. Around forty tasks are covered across nine categories. Everything is generated in your browser; nothing you type is sent anywhere, and the tool never connects to your tenant.
It is aimed at the Microsoft 365 administrator who knows exactly what needs to happen but not the exact parameter names — which is most of us, most of the time. Is it -User or -Trustee? Does Send As use Add-MailboxPermission or Add-RecipientPermission? Is Get-MessageTrace still a thing? The builder answers those questions by producing correct syntax rather than by making you look each one up.
Every task except the install itself assumes you are connected. Install the module once:
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -ForceLater, update it with:
Update-Module -Name ExchangeOnlineManagement
Then connect. Interactive sign-in handles MFA through a browser prompt:
Connect-ExchangeOnline -UserPrincipalName admin@contoso.com -ShowBanner:$false
And always disconnect when you are done, so you do not leave a session holding a token:
Disconnect-ExchangeOnline -Confirm:$false
The builder also covers certificate-based authentication (Connect-ExchangeOnline -CertificateThumbprint with an app ID and organisation, for unattended scripts), app-only authentication with a managed identity (Connect-ExchangeOnline -ManagedIdentity), and the -DisableWAM switch that resolves the Web Account Manager broker sign-in failures some workstations hit. For a full walkthrough of installing the module, dealing with execution policy and troubleshooting first-connection errors, see our guide on how to install and connect to Exchange Online PowerShell.
Each task also shows the underlying cmdlet and the role or permission you need to run it — Exchange Administrator for most changes, View-Only Recipients or Global Reader for the read-only reports.
This is the area where the wrong cmdlet gets used most often, because the three permissions look similar and behave completely differently.
Full Access lets someone open the mailbox and read everything in it. It does not let them send as the mailbox:
Add-MailboxPermission -Identity "shared@contoso.com" `
-User "jdoe@contoso.com" `
-AccessRights FullAccess -InheritanceType All -AutoMapping $true
Send As makes mail appear to come from the mailbox itself, with no trace of the actual sender in the From line. It is a different cmdlet entirely — Add-RecipientPermission, with -Trustee rather than -User:
Add-RecipientPermission -Identity "shared@contoso.com" `
-Trustee "jdoe@contoso.com" `
-AccessRights SendAs -Confirm:$false
Send on Behalf shows recipients “jdoe on behalf of shared”, and is set as a property of the mailbox:
Set-Mailbox -Identity "shared@contoso.com" `
-GrantSendOnBehalfTo @{Add="jdoe@contoso.com"}
Two practical notes. The @{Add=…} hashtable syntax on -GrantSendOnBehalfTo appends to the existing list; assigning a plain value replaces it, silently removing everyone else. And -AutoMapping $true makes the shared mailbox appear automatically in Outlook, which is usually what people want — but for a mailbox with tens of thousands of items it can slow Outlook noticeably, so set it to $false and have users add the mailbox manually in that case.
Attacker-configured mail forwarding is one of the most durable post-compromise persistence techniques in Microsoft 365, and it hides in two separate places. Server-side forwarding is a mailbox property; user-created inbox rules are separate objects. A complete audit checks both:
# Every mailbox with server-side forwarding configured Get-EXOMailbox -ResultSize Unlimited -PropertySets Delivery | Where-Object { $_.ForwardingAddress -or $_.ForwardingSmtpAddress } | Select-Object DisplayName, PrimarySmtpAddress, ForwardingAddress, ForwardingSmtpAddress, DeliverToMailboxAndForward | Export-Csv -Path "C:\Reports\forwarding.csv" -NoTypeInformationUser-created inbox rules that forward or redirect
Get-EXOMailbox -ResultSize Unlimited | ForEach-Object { Get-InboxRule -Mailbox $.PrimarySmtpAddress | Where-Object { $.ForwardTo -or $.ForwardAsAttachmentTo -or $.RedirectTo } }
Run the audit, then close the gap with a transport rule that blocks external auto-forwarding outright — the builder generates that rule too. Note the Get-EXO* cmdlets used here: the REST-backed V3 cmdlets such as Get-EXOMailbox are substantially faster than their classic equivalents on large tenants, and -PropertySets keeps the payload small by fetching only the property group you need.
When a user reports a missing message, trace it:
Get-MessageTraceV2 -SenderAddress "sender@contoso.com" `
-StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date) |
Format-Table Received, SenderAddress, RecipientAddress, Subject, Status -AutoSize
Get-MessageTraceV2 covers up to 90 days and replaces the retired Get-MessageTrace. If you have older scripts still calling the original cmdlet, that is why they stopped working. You can also filter by delivery status — Failed, Delivered, Pending, Quarantined or FilteredAsSpam — which is usually the fastest route to a deliverability answer.
These commands change production mail flow and access. Read the generated command before running it, run reporting tasks before change tasks, and test permission and forwarding changes on a single test mailbox first. Bulk operations built from a CSV in particular deserve a dry run — pipe to Select-Object and inspect the list before you pipe it to a cmdlet that writes.
Mail-flow problems that turn out to be DNS problems are common: check the domain’s records with the DNS lookup tool, and build or repair authentication records with the SPF generator and DMARC generator. For CSV and report output you need to reshape, the JSON formatter is a useful companion.
Run Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -Force. Drop -Scope CurrentUser and run PowerShell as administrator if you want it installed for all users on the machine.
Use Connect-ExchangeOnline -UserPrincipalName admin@contoso.com. The V3 module handles multi-factor authentication through an interactive browser prompt by default — there is no separate MFA module any more.
No. It generates command text only. Nothing you enter — mailbox addresses, tenant names, app IDs, thumbprints — leaves your browser, and no credentials are ever requested.
Full Access lets someone open and read a mailbox. Send As lets them send mail that appears to originate from it. They are separate permissions set by different cmdlets, and delegating a shared mailbox usually requires both.
Because Full Access was granted and Send As was not. Add the Send As permission with Add-RecipientPermission. Also allow time for the change to replicate — permission changes in Exchange Online are not always instant.
Get-MessageTraceV2. It supports a 90-day window and is the supported cmdlet going forward; the original has been retired.
REST-backed V3 cmdlets such as Get-EXOMailbox and Get-EXOMailboxStatistics, designed for bulk and reporting work. They are considerably faster on large tenants and support -PropertySets to limit which properties are retrieved.
Use certificate-based app-only authentication: register an Entra ID application, grant it the Exchange.ManageAsApp permission, upload a certificate, and connect with Connect-ExchangeOnline -CertificateThumbprint <thumbprint> -AppId <app-id> -Organization contoso.onmicrosoft.com. On an Azure-hosted runner, a managed identity avoids handling a certificate at all.
Exchange Administrator covers most changes. Read-only reporting and message trace generally need only View-Only Recipients or Global Reader. Each task in the builder states its own requirement, so you can request the minimum rather than defaulting to Global Administrator.
Some workstations hit failures in the Web Account Manager sign-in broker. Add -DisableWAM to Connect-ExchangeOnline to fall back to the browser-based flow. The builder includes this as a dedicated task.
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.
| 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 |
Connect-ExchangeOnline from the ExchangeOnlineManagement module (v3+). This supports modern authentication, certificate-based auth, and REST-based cmdlets.-ResultSize to limit query results. Querying all mailboxes in a large tenant without limits can timeout or consume excessive resources.-WhatIf to preview what would change without making actual modifications.Disconnect-ExchangeOnline when done. Exchange Online limits the number of concurrent PowerShell sessions per tenant.First install the module with Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -Force. Then run Connect-ExchangeOnline -UserPrincipalName admin@contoso.com. A browser prompt handles sign-in and MFA automatically. For unattended scripts use certificate-based auth (Connect-ExchangeOnline -AppId ... -CertificateThumbprint ... -Organization ...) or app-only auth with a managed identity. Always finish with Disconnect-ExchangeOnline.
There are three distinct permissions. Use Add-MailboxPermission -Identity target@contoso.com -User jdoe@contoso.com -AccessRights FullAccess for full access (opening the mailbox). Use Add-RecipientPermission ... -AccessRights SendAs for Send As (mail appears to come from the mailbox). Use Set-Mailbox -GrantSendOnBehalfTo for Send on Behalf. The builder generates the exact command for each.
For an internal recipient use Set-Mailbox -ForwardingAddress; for an external SMTP address use -ForwardingSmtpAddress. Add -DeliverToMailboxAndForward $true to keep a copy in the original mailbox. To stop forwarding, set both -ForwardingAddress $null and -ForwardingSmtpAddress $null. Note that external auto-forwarding is often blocked by the outbound anti-spam policy.
This is a key security check. Run Get-EXOMailbox -ResultSize Unlimited and filter where ForwardingAddress or ForwardingSmtpAddress is set, then export to CSV. Also enumerate user-created inbox rules with Get-InboxRule and flag any with ForwardTo, ForwardAsAttachmentTo, or RedirectTo, since attackers commonly use these to exfiltrate mail. The Forwarding category in this tool builds the full audit script.
Create one with New-Mailbox -Shared -Name "Support" -PrimarySmtpAddress support@contoso.com, then grant members FullAccess and SendAs. To convert an existing user mailbox, run Set-Mailbox -Identity user@contoso.com -Type Shared. Shared mailboxes under 50 GB do not require a license, so remember to remove the license after converting.
Microsoft retired the original Get-MessageTrace and Get-MessageTraceDetail cmdlets. Use Get-MessageTraceV2 instead. It supports searching by sender, recipient, date range (up to 90 days), and delivery status (Failed, Delivered, Pending, Quarantined, FilteredAsSpam). The Message Trace category in this tool generates V2 commands.
View current permissions with Get-MailboxFolderPermission -Identity user@contoso.com:\Calendar. Grant new access with Add-MailboxFolderPermission and an access level such as Reviewer, Editor, or AvailabilityOnly. If the user is already listed you must use Set-MailboxFolderPermission instead of Add-, otherwise the command errors. The builder picks the correct cmdlet for you.
On servers or non-interactive desktops the Web Account Manager (WAM) broker can cause the sign-in window to hang or fail. Add the -DisableWAM switch: Connect-ExchangeOnline -UserPrincipalName admin@contoso.com -DisableWAM. This falls back to the standard browser-based auth flow. Keeping the module updated with Update-Module ExchangeOnlineManagement also resolves many auth issues.