Exchange Online PowerShell commands cheat sheet

Everyday Exchange Online admin tasks from the ExchangeOnlineManagement V3 module. Role-based access control decides which cmdlets and parameters you can run after you connect.

Covers
ExchangeOnlineManagement module 3.x (REST-based cmdlets)
Commands
55
Last verified

Install and connect

CommandWhat it does
Install-Module -Name ExchangeOnlineManagement

Install the Exchange Online PowerShell module from the PowerShell Gallery.

Example
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser

Versions 3.10.0 and later need PowerShell 7.6 or later on PowerShell 7; Windows PowerShell 5.1 is not affected.

Update-Module -Name ExchangeOnlineManagement

Update an existing installation to the latest release.

Example
Update-Module -Name ExchangeOnlineManagement -Scope CurrentUser
Import-Module ExchangeOnlineManagement

Load the module into the current session.

Usually optional: running Connect-ExchangeOnline loads an installed module for you.

Connect-ExchangeOnline -UserPrincipalName <UPN>

Sign in to Exchange Online PowerShell with modern authentication, with or without MFA.

Example
Connect-ExchangeOnline -UserPrincipalName [email protected]

Add -Device on a machine without a browser, or -DelegatedOrganization <tenant>.onmicrosoft.com to manage a customer tenant as a partner.

Get-ConnectionInformation

List the active REST-based connections in this PowerShell window.

Get-PSSession does not show REST connections, so use this instead.

Disconnect-ExchangeOnline -Confirm:$false

Close the session without a confirmation prompt.

Always disconnect when finished; abandoned sessions count against your limit until they expire.

Mailboxes

CommandWhat it does
Get-EXOMailbox -ResultSize Unlimited

List every mailbox with a minimal, fast set of properties.

The default is 1000 results. Add -Properties or -PropertySets (for example Quota, Archive, Delivery) for more fields.

Get-EXOMailbox -RecipientTypeDetails SharedMailbox

List mailboxes of one subtype, such as shared or room mailboxes.

Example
Get-EXOMailbox -RecipientTypeDetails SharedMailbox,RoomMailbox -ResultSize Unlimited
Get-EXOMailbox -Identity <mailbox> -Properties <list>

Show chosen properties for one mailbox.

Example
Get-EXOMailbox -Identity [email protected] -Properties DisplayName,EmailAddresses,Alias
Get-Mailbox -Identity <mailbox>

Show the full property set for a mailbox, including properties Get-EXOMailbox leaves out.

Example
Get-Mailbox -Identity [email protected] | Format-List

Slower than Get-EXOMailbox for bulk queries; use it for single mailboxes.

Get-EXOMailboxStatistics -Identity <mailbox>

Show mailbox size, item count and deleted item size.

Example
Get-EXOMailboxStatistics -Identity [email protected]

Add -Archive to get the same figures for the archive mailbox.

New-Mailbox -Shared -Name <name>

Create a shared mailbox.

Example
New-Mailbox -Shared -Name "Sales Department" -DisplayName "Sales Department" -Alias Sales
Set-Mailbox -Identity <mailbox> -Type Shared

Convert a user mailbox to a shared mailbox.

Example
Set-Mailbox -Identity [email protected] -Type Shared

Use -Type Regular to convert back. Other values: Room, Equipment.

Set-Mailbox -Identity <mailbox> -EmailAddresses @{Add="<address>"}

Add a secondary SMTP address without touching existing addresses.

Example
Set-Mailbox -Identity [email protected] -EmailAddresses @{Add="[email protected]"}

Use @{Remove="<address>"} to remove one. Listing addresses without Add or Remove replaces them all.

Set-Mailbox -Identity <mailbox> -HiddenFromAddressListsEnabled $true

Hide a mailbox from the global address list.

Example
Set-Mailbox -Identity [email protected] -HiddenFromAddressListsEnabled $true

Mailbox permissions

CommandWhat it does
Add-MailboxPermission -Identity <mailbox> -User <user> -AccessRights FullAccess

Give a user full access to open another mailbox.

Example
Add-MailboxPermission -Identity [email protected] -User [email protected] -AccessRights FullAccess -InheritanceType All -AutoMapping $false

-AutoMapping $false stops Outlook adding the mailbox automatically. The default is $true.

Get-EXOMailboxPermission -Identity <mailbox>

List who has permissions on a mailbox.

Example
Get-EXOMailboxPermission -Identity [email protected] -User [email protected]
Remove-MailboxPermission -Identity <mailbox> -User <user> -AccessRights FullAccess

Take away a user's full access to a mailbox.

Example
Remove-MailboxPermission -Identity [email protected] -User [email protected] -AccessRights FullAccess -InheritanceType All

Warning: Warning: the user loses access to the mailbox immediately. Confirm the user and mailbox before running it.

Add-RecipientPermission -Identity <mailbox> -AccessRights SendAs -Trustee <user>

Let a user send mail that appears to come directly from the mailbox.

Example
Add-RecipientPermission -Identity [email protected] -AccessRights SendAs -Trustee [email protected]
Get-EXORecipientPermission -Identity <mailbox>

List Send As permissions on a mailbox.

Example
Get-EXORecipientPermission -Identity [email protected]
Remove-RecipientPermission -Identity <mailbox> -AccessRights SendAs -Trustee <user>

Remove a user's Send As permission.

Example
Remove-RecipientPermission -Identity [email protected] -AccessRights SendAs -Trustee [email protected]

Warning: Warning: the user can no longer send as the mailbox. Confirm the trustee first.

Set-Mailbox -Identity <mailbox> -GrantSendOnBehalfTo @{Add="<user>"}

Let a user send on behalf of the mailbox without replacing existing delegates.

Example
Set-Mailbox -Identity [email protected] -GrantSendOnBehalfTo @{Add="[email protected]"}

Recipients see "<sender> on behalf of <mailbox>". Without @{Add=...} the list is overwritten.

Forwarding and inbox rules

CommandWhat it does
Set-Mailbox -Identity <mailbox> -ForwardingSmtpAddress <address> -DeliverToMailboxAndForward $true

Forward a mailbox's mail to another address and keep a copy in the mailbox.

Example
Set-Mailbox -Identity [email protected] -ForwardingSmtpAddress [email protected] -DeliverToMailboxAndForward $true

With -DeliverToMailboxAndForward $false (the default) mail is only forwarded, not kept.

Set-Mailbox -Identity <mailbox> -ForwardingSmtpAddress $null

Turn off SMTP forwarding on a mailbox.

Example
Set-Mailbox -Identity [email protected] -ForwardingSmtpAddress $null
Get-EXOMailbox -ResultSize Unlimited -PropertySets Delivery

Audit forwarding settings across all mailboxes.

Example
Get-EXOMailbox -ResultSize Unlimited -PropertySets Delivery | Where-Object {$_.ForwardingSmtpAddress -or $_.ForwardingAddress} | Select-Object UserPrincipalName,ForwardingSmtpAddress,ForwardingAddress,DeliverToMailboxAndForward

The Delivery property set includes ForwardingAddress, ForwardingSmtpAddress and DeliverToMailboxAndForward.

Get-InboxRule -Mailbox <mailbox>

List a mailbox's Inbox rules.

Example
Get-InboxRule -Mailbox [email protected] -IncludeHidden | Where-Object {$_.ForwardTo -or $_.ForwardAsAttachmentTo -or $_.RedirectTo}

-IncludeHidden also returns hidden rules. Filtering on ForwardTo, ForwardAsAttachmentTo and RedirectTo finds rules that send mail elsewhere, a common sign of a compromised account.

Remove-InboxRule -Mailbox <mailbox> -Identity <rule>

Delete an Inbox rule from a mailbox.

Example
Remove-InboxRule -Mailbox [email protected] -Identity "Forward to external"

Warning: Warning: the rule is deleted permanently. Piping Get-InboxRule into Remove-InboxRule removes every rule in the mailbox.

Mail flow and message trace

CommandWhat it does
Get-MessageTraceV2 -SenderAddress <address> -StartDate <date> -EndDate <date>

Trace messages from a sender over a date range.

Example
Get-MessageTraceV2 -SenderAddress [email protected] -StartDate 10/20/2026 -EndDate 10/27/2026

Replaces Get-MessageTrace, which Microsoft is deprecating. Searches the last 90 days, at most 10 days per query; returns 1000 results by default and up to 5000 with -ResultSize. Dates use your computer's short date format.

Get-MessageTraceV2 -RecipientAddress <address> -Status Failed

Find messages to a recipient that failed delivery.

Example
Get-MessageTraceV2 -RecipientAddress [email protected] -Status Failed,Quarantined

Without dates it covers the last 48 hours. Other -Status values: Delivered, Expanded, FilteredAsSpam, GettingStatus, Pending.

Get-MessageTraceDetailV2 -MessageTraceId <guid> -RecipientAddress <address>

Show the event-by-event detail of one traced message.

Example
Get-MessageTraceV2 -SenderAddress [email protected] -StartDate 10/20/2026 -EndDate 10/27/2026 | Get-MessageTraceDetailV2
Get-TransportRule

List mail flow (transport) rules.

Example
Get-TransportRule "External subject tag" | Format-List
New-TransportRule -Name <name> -FromScope NotInOrganization -PrependSubject <text>

Create a mail flow rule that tags the subject of mail from outside the organisation.

Example
New-TransportRule -Name "External subject tag" -FromScope NotInOrganization -PrependSubject "[External] "

Add -Mode Audit to log what the rule would do without changing messages. Enforce is the default.

Get-AcceptedDomain

List the domains the tenant accepts mail for; also a quick test that you are connected.

Archive, retention and holds

CommandWhat it does
Enable-Mailbox -Identity <mailbox> -Archive

Turn on the archive mailbox for an existing mailbox.

Example
Enable-Mailbox -Identity [email protected] -Archive
Get-EXOMailbox -Archive -ResultSize Unlimited

List only mailboxes that have an archive enabled.

Set-Mailbox -Identity <mailbox> -RetentionPolicy <policy>

Assign a messaging records management (MRM) retention policy to a mailbox.

Example
Set-Mailbox -Identity [email protected] -RetentionPolicy "Default MRM Policy"
Start-ManagedFolderAssistant -Identity <mailbox>

Ask the Managed Folder Assistant to process a mailbox's retention settings now.

Example
Start-ManagedFolderAssistant -Identity [email protected]

Useful after enabling an archive or changing a retention policy instead of waiting for the next scheduled run.

Set-Mailbox -Identity <mailbox> -LitigationHoldEnabled $true

Place a mailbox on Litigation Hold so deleted and changed items are kept.

Example
Set-Mailbox -Identity [email protected] -LitigationHoldEnabled $true -LitigationHoldDuration 2555

-LitigationHoldDuration is in days from when each item was received or created; the default is unlimited.

Distribution lists and Microsoft 365 groups

CommandWhat it does
Get-DistributionGroup -ResultSize Unlimited

List distribution groups and mail-enabled security groups.

Example
Get-DistributionGroup -Identity "Marketing" | Format-List
New-DistributionGroup -Name <name> -Members <list>

Create a distribution group with initial members.

Example
New-DistributionGroup -Name "ITDepartment" -Members [email protected],[email protected]

Add -Type Security to create a mail-enabled security group instead.

Get-DistributionGroupMember -Identity <group>

List the members of a distribution group.

Example
Get-DistributionGroupMember -Identity "ITDepartment" -ResultSize Unlimited
Add-DistributionGroupMember -Identity <group> -Member <recipient>

Add a member to a distribution group.

Example
Add-DistributionGroupMember -Identity "ITDepartment" -Member [email protected]
Remove-DistributionGroupMember -Identity <group> -Member <recipient>

Remove a member from a distribution group.

Example
Remove-DistributionGroupMember -Identity "ITDepartment" -Member [email protected]

Warning: Warning: the member stops receiving the group's mail and loses any access granted through the group.

Get-UnifiedGroup -ResultSize Unlimited

List Microsoft 365 groups.

Example
Get-UnifiedGroup | Where-Object {-Not $_.ManagedBy}

The example finds groups with no owner.

Get-UnifiedGroupLinks -Identity <group> -LinkType Members

List the members (or owners) of a Microsoft 365 group.

Example
Get-UnifiedGroupLinks -Identity "Legal Department" -LinkType Owners
Add-UnifiedGroupLinks -Identity <group> -LinkType Members -Links <list>

Add members (or owners) to a Microsoft 365 group.

Example
Add-UnifiedGroupLinks -Identity "Legal Department" -LinkType Members -Links [email protected],[email protected]

With this cmdlet a user must be a member before you can add them with -LinkType Owners.

Calendars and automatic replies

CommandWhat it does
Add-MailboxFolderPermission -Identity <mailbox>:\Calendar -User <user> -AccessRights <role>

Share a calendar with a user at a given permission level.

Example
Add-MailboxFolderPermission -Identity [email protected]:\Calendar -User [email protected] -AccessRights Editor -SharingPermissionFlags Delegate

Common roles: AvailabilityOnly, LimitedDetails, Reviewer, Editor, Owner. -SharingPermissionFlags Delegate makes the user a calendar delegate.

Get-EXOMailboxFolderPermission -Identity <mailbox>:\Calendar

List who has access to a calendar and at what level.

Example
Get-EXOMailboxFolderPermission -Identity [email protected]:\Calendar
Set-MailboxFolderPermission -Identity <mailbox>:\Calendar -User <user> -AccessRights <role>

Change an existing calendar permission.

Example
Set-MailboxFolderPermission -Identity [email protected]:\Calendar -User [email protected] -AccessRights Reviewer

Set- modifies an existing permission entry; use Add- for a user who has no entry yet.

Remove-MailboxFolderPermission -Identity <mailbox>:\Calendar -User <user>

Remove a user's access to a calendar.

Example
Remove-MailboxFolderPermission -Identity [email protected]:\Calendar -User [email protected]

Warning: Warning: the user immediately loses the calendar, including any delegate rights.

Set-CalendarProcessing -Identity <resource> -AutomateProcessing AutoAccept

Make a room or equipment mailbox accept or decline bookings automatically.

Example
Set-CalendarProcessing -Identity "Room 221" -AutomateProcessing AutoAccept -AllowConflicts $false

None disables processing; AutoUpdate leaves requests tentative until a delegate approves.

Get-CalendarProcessing -Identity <resource>

Show a resource mailbox's booking settings.

Example
Get-CalendarProcessing -Identity "Room 221" | Format-List
Set-MailboxAutoReplyConfiguration -Identity <mailbox> -AutoReplyState Scheduled

Schedule out-of-office replies for a mailbox.

Example
Set-MailboxAutoReplyConfiguration -Identity [email protected] -AutoReplyState Scheduled -StartTime "11/03/2026 08:00" -EndTime "11/07/2026 17:00" -InternalMessage "I am out of the office this week." -ExternalMessage "I am out of the office this week." -ExternalAudience All

Use -AutoReplyState Enabled to start now with no end date. -ExternalAudience accepts None, Known or All.

Set-MailboxAutoReplyConfiguration -Identity <mailbox> -AutoReplyState Disabled

Turn off automatic replies.

Example
Set-MailboxAutoReplyConfiguration -Identity [email protected] -AutoReplyState Disabled
Get-MailboxAutoReplyConfiguration -Identity <mailbox>

Show a mailbox's automatic reply state and messages.

Example
Get-MailboxAutoReplyConfiguration -Identity [email protected]

Official references

Last verified against these pages. Commands marked Warning restart, erase or remove something: run them only in a maintenance window and with a backup.

  1. About the Exchange Online PowerShell V3 module learn.microsoft.com
  2. Connect to Exchange Online PowerShell learn.microsoft.com
  3. Property sets in Exchange Online PowerShell module cmdlets learn.microsoft.com
  4. Get-EXOMailbox learn.microsoft.com
  5. Set-Mailbox learn.microsoft.com
  6. Add-MailboxPermission learn.microsoft.com
  7. Get-MessageTraceV2 learn.microsoft.com
  8. Add-MailboxFolderPermission learn.microsoft.com

Questions people ask

How do I connect to Exchange Online PowerShell?

Install the module with Install-Module -Name ExchangeOnlineManagement, then run Connect-ExchangeOnline -UserPrincipalName [email protected] and sign in (MFA is supported). When you are done, run Disconnect-ExchangeOnline -Confirm:$false so the session does not count against your limit.

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

Get-EXOMailbox is one of the REST-based Get-EXO* cmdlets in the V3 module. It returns a minimal property set by default, so it is much faster for thousands of mailboxes; ask for more with -Properties or -PropertySets. Get-Mailbox returns every property and suits one-off lookups.

Is Get-MessageTrace deprecated?

Yes. Microsoft Learn marks Get-MessageTrace as replaced by Get-MessageTraceV2, and Get-MessageTraceDetail by Get-MessageTraceDetailV2. The V2 cmdlets search 90 days of data, up to 10 days per query, and use -ResultSize (up to 5000) instead of the old paging parameters.

How do I give someone full access and Send As on a shared mailbox?

Run Add-MailboxPermission -Identity [email protected] -User [email protected] -AccessRights FullAccess for full access, then Add-RecipientPermission -Identity [email protected] -AccessRights SendAs -Trustee [email protected] for Send As. Check the result with Get-EXOMailboxPermission and Get-EXORecipientPermission.

© EpiFive · www.epifive.com/cheatsheets/exchange-online-powershell · Last verified 28 October 2026. Free to share unchanged. Check the official references before you change a production system.