Skip to main content

Mailbox helpers

Requires an EXO session. For full details and examples, run Get-Help <FunctionName> -Detailed.

Add-MboxAlias

Add SMTP aliases on a recipient.

Syntax

Add-MboxAlias -SourceMailbox <String> -MailboxAlias <String>
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)StringTarget mailbox/recipient. Pipeline accepted.Yes-
MailboxAliasStringAlias (SMTP address) to add.Yes-

Examples

Add-MboxAlias -SourceMailbox 'user@contoso.com' -MailboxAlias 'alias@contoso.com'
Add-MboxAlias -Identity 'user@contoso.com' -MailboxAlias 'alias@contoso.com'

Add-MboxPermission

Grant mailbox permissions.

Syntax

Add-MboxPermission -SourceMailbox <String> -UserMailbox <String[]> [-AccessRights <String>] [-AutoMapping] [-PassThru]
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)StringTarget mailbox.Yes-
UserMailboxString[]One or more principals to grant. Pipeline accepted.Yes-
AccessRightsStringRights: All, FullAccess, SendAs, SendOnBehalfTo.NoAll
AutoMappingSwitchEnable/disable Outlook automapping.NoFalse
PassThruSwitchEmit detailed permission objects (default shows only confirmation messages).NoFalse

Examples

Add-MboxPermission -SourceMailbox 'sharedmailbox@contoso.com' -UserMailbox 'user@contoso.com' -AccessRights FullAccess -AutoMapping:$false
Add-MboxPermission -SourceMailbox 'sharedmailbox@contoso.com' -UserMailbox 'user@contoso.com' -PassThru

Export-MboxPermission

Export mailbox permissions to CSV with optional batching and resume support.

Syntax

Export-MboxPermission -RecipientType <String> [-CsvFolder <String>] [-BatchSize <Int32>] [-Resume] [-CsvPath <String>] [-MaxConsecutiveErrors <Int32>]
ParameterTypeDescriptionRequiredDefault
RecipientTypeStringRecipient type to analyze: User, Shared, Room, or All.Yes-
CsvFolderStringDestination folder for the CSV.NoCurrent directory
BatchSizeInt32Number of processed mailboxes buffered before the CSV is flushed.No25
ResumeSwitchResume from the latest matching CSV or from -CsvPath.NoFalse
CsvPathStringExplicit CSV file to resume. When omitted, the latest matching CSV is used.No-
MaxConsecutiveErrorsInt32Stop after this many consecutive mailbox-level failures.No5

Examples

Export-MboxPermission -RecipientType All -CsvFolder 'C:\Temp' -Resume
Export-MboxPermission -RecipientType Shared -CsvFolder 'C:\Temp' -CsvPath 'C:\Temp\20260414_M365-MboxPermissions-Report.csv'

Export-MboxAlias

:::warning Deprecated function Export-MboxAlias is deprecated and no longer available as a function. Use Get-MboxAlias instead. :::

Get-MboxAlias

List aliases for auditing. This also replaces Export-MboxAlias.

Get-MboxAlias is now the single command for alias reporting. It supports:

  • a single mailbox or recipient identity
  • tenant-wide export with -All
  • domain-scoped export with -Domain
  • CSV output for single mailbox queries with -Csv and -CsvFolder
  • automatic CSV export for -All and -Domain
  • batch flushing and resume for long-running CSV exports with -BatchSize, -Resume, -CsvPath, and -MaxConsecutiveErrors
  • optional inclusion of primary-only recipients with -IncludePrimaryOnly
  • extra CSV fields DisplayName and Name
  • extra CSV fields UserPrincipalName and IsMoera in CSV exports

Note:

  • -Csv is the explicit switch for single-mailbox exports.
  • -All and -Domain already export to CSV, so -Csv is optional in those modes.
  • -CsvFolder controls the export destination for every CSV-producing mode.
  • -Resume reuses the latest matching CSV in the target folder unless -CsvPath is specified.
  • -BatchSize controls how many processed recipients are buffered before the CSV is flushed.
  • -IncludePrimaryOnly keeps recipients that would otherwise be omitted because they have no secondary aliases.
  • -IncludeMoera keeps addresses in the tenant's onmicrosoft.com domain that would otherwise be hidden.
  • Primary-only exclusion is evaluated after MOERA filtering, so a mailbox with only a primary SMTP and a MOERA proxy stays hidden by default.

Syntax

Get-MboxAlias -SourceMailbox <String> [-Csv] [-CsvFolder <String>] [-IncludePrimaryOnly] [-IncludeMoera] [-BatchSize <Int32>] [-Resume] [-CsvPath <String>] [-MaxConsecutiveErrors <Int32>] [-All] [-Domain <String>]
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)StringTarget mailbox/recipient. Pipeline accepted.Yes in single mode-
CsvSwitchForce CSV export for a single mailbox query. Optional when using -All or -Domain.NoFalse
CsvFolderStringDestination folder for CSV export.No-
IncludePrimaryOnlySwitchInclude recipients with only a primary SMTP address in CSV exports.NoFalse
IncludeMoeraSwitchInclude MOERA addresses in CSV exports.NoFalse
BatchSizeInt32Number of processed recipients to buffer before flushing the CSV.No25
ResumeSwitchResume from the latest matching CSV or from -CsvPath.NoFalse
CsvPathStringExplicit CSV file to resume. When omitted, the latest matching CSV is used.No-
MaxConsecutiveErrorsInt32Stop after this many consecutive recipient-level failures.No5
AllSwitchExport aliases for all non-guest recipients and write a CSV report.NoFalse
DomainStringExport aliases for recipients matching a domain and write a CSV report.No-

Examples

Get-MboxAlias -SourceMailbox 'user@contoso.com'
Get-MboxAlias 'user@contoso.com'
Get-MboxAlias -SourceMailbox 'user@contoso.com' -Csv -CsvFolder 'C:\Temp'
Get-MboxAlias -SourceMailbox 'user@contoso.com' -Csv -IncludePrimaryOnly -CsvFolder 'C:\Temp'
Get-MboxAlias -SourceMailbox 'user@contoso.com' -Csv -IncludeMoera -CsvFolder 'C:\Temp'

Example behavior:

  • Get-MboxAlias -SourceMailbox 'user@contoso.com' -Csv hides the MOERA row and keeps the mailbox only if it has a real secondary alias.
  • Get-MboxAlias -SourceMailbox 'user@contoso.com' -Csv -IncludeMoera includes the MOERA row as well.
Get-MboxAlias -All -CsvFolder 'C:\Temp'
Get-MboxAlias -Domain 'contoso.com' -CsvFolder 'C:\Temp'
Get-MboxAlias -All -CsvFolder 'C:\Temp' -Resume
Get-MboxAlias -Domain 'contoso.com' -CsvFolder 'C:\Temp' -Resume -CsvPath 'C:\Temp\20260414_M365-Alias-Report.csv'

Get-MboxLastMessageTrace

Return the most recent received and sent message traces for a mailbox.

Syntax

Get-MboxLastMessageTrace -SourceMailbox <String> [-IncludeTrace]
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)StringTarget mailbox/recipient. Pipeline accepted.No-
IncludeTraceSwitchInclude raw message trace objects in the output.NoFalse

Example

Get-MboxLastMessageTrace -SourceMailbox 'user@contoso.com'
Get-MboxLastMessageTrace -SourceMailbox 'user@contoso.com' -IncludeTrace

Get-MboxPermission

List mailbox permissions.

Syntax

Get-MboxPermission -Identity <String>
ParameterTypeDescriptionRequiredDefault
IdentityStringTarget mailbox.Yes-

Examples

Get-MboxPermission -Identity 'sharedmailbox@contoso.com'

Get-MboxPrimarySmtpAddress

Return the PrimarySmtpAddress for a mailbox or recipient.

Syntax

Get-MboxPrimarySmtpAddress -SourceMailbox <String[]> [-Raw] [-Detailed]
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)String[]Target mailbox/recipient. Pipeline accepted.Yes-
RawSwitchReturn only the PrimarySmtpAddress values.NoFalse
DetailedSwitchInclude additional fields (Identity, RecipientTypeDetails).NoFalse
tip

Get-MboxPrimarySmtpAddress is also available as gpa (alias).

By default, object output is compact and optimized for console readability:

  • DisplayName
  • PrimarySmtpAddress

Example

Get-MboxPrimarySmtpAddress -SourceMailbox 'user@contoso.com'
Get-MboxPrimarySmtpAddress -SourceMailbox 'user@contoso.com' -Raw
gpa 'user@contoso.com' -Raw
Get-MboxPrimarySmtpAddress -SourceMailbox 'user@contoso.com' -Detailed

Get-UserLastSeen

Return the most recent activity for a mailbox combining Exchange LastUserActionTime and (when available) Entra ID sign-in logs.

Syntax

Get-UserLastSeen -User <String>
ParameterTypeDescriptionRequiredDefault
User (Identity, UserPrincipalName)StringTarget mailbox identity. Pipeline accepted.No-

Example

Get-UserLastSeen -User 'user@contoso.com'

Notes:

  • Requires Exchange Online connection. Graph sign-in logs are included when AuditLog.Read.All + Directory.Read.All scopes are available.
  • Output includes LastUserActionTime, LastInteractiveSignIn, LastSeen, and the Source used.

New-SharedMailbox

Create a shared mailbox.

Syntax

New-SharedMailbox -SharedMailboxSMTPAddress <String> -SharedMailboxDisplayName <String> -SharedMailboxAlias <String>
ParameterTypeDescriptionRequiredDefault
SharedMailboxSMTPAddressStringPrimary SMTP address of the new shared mailbox.Yes-
SharedMailboxDisplayNameStringDisplay name.Yes-
SharedMailboxAliasStringMail alias.Yes-

Example

New-SharedMailbox -SharedMailboxSMTPAddress 'sharedmailbox@contoso.com' -SharedMailboxDisplayName 'Support Team' -SharedMailboxAlias 'SupportTeam'

Remove-MboxAlias

Remove SMTP aliases from a recipient.

Syntax

Remove-MboxAlias -SourceMailbox <String> -MailboxAlias <String>
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)StringTarget mailbox/recipient. Pipeline accepted.Yes-
MailboxAliasStringAlias (SMTP address) to remove.Yes-

Examples

Remove-MboxAlias -SourceMailbox 'user@contoso.com' -MailboxAlias 'alias@contoso.com'

Remove-MboxPermission

Revoke mailbox permissions.

Syntax

Remove-MboxPermission -SourceMailbox <String> -UserMailbox <String[]> [-AccessRights <String>]
Remove-MboxPermission -SourceMailbox <String> -ClearAll
Remove-MboxPermission <SourceMailbox> <UserMailbox> [-AccessRights <String>]
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)StringTarget mailbox.Yes-
UserMailboxString[]Principal(s) to revoke.Yes (User mode)-
AccessRightsStringRights (e.g., FullAccess, SendAs, SendOnBehalfTo). Defaults to All.NoAll
ClearAllSwitchRemove all non-inherited FullAccess, SendAs, and SendOnBehalfTo permissions from the source mailbox.Yes (All mode)-

Examples

Remove-MboxPermission -SourceMailbox 'sharedmailbox@contoso.com' -UserMailbox 'user@contoso.com' -AccessRights FullAccess
# Positional call (SourceMailbox = position 0, UserMailbox = position 1)
Remove-MboxPermission 'sharedmailbox@contoso.com' 'user@contoso.com'
Remove-MboxPermission -SourceMailbox 'sharedmailbox@contoso.com' -ClearAll

Set-MboxLanguage

Set mailbox UI language and regional defaults.

Syntax

Set-MboxLanguage -SourceMailbox <String[]> [-Language <String>]
Set-MboxLanguage -Csv <String> [-Language <String>]
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)String[]Target mailbox(es). Pipeline accepted.No-
CsvStringCSV file path containing EmailAddress column.No-
LanguageStringCulture code (e.g., it-IT, en-US).Noit-IT

Example

Set-MboxLanguage -SourceMailbox 'user@contoso.com' -Language it-IT
Set-MboxLanguage -Csv 'C:\Temp\mailboxes.csv' -Language en-US

Set-MboxRulesQuota

Set rules quota to 256KB for one or more mailboxes.

Syntax

Set-MboxRulesQuota -SourceMailbox <String[]>
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)String[]Target mailbox(es). Pipeline accepted.No-

Example

Set-MboxRulesQuota -SourceMailbox 'user@contoso.com','sharedmailbox@contoso.com'

Set-SharedMboxCopyForSent

Enable sent-item copy settings for shared mailboxes.

Syntax

Set-SharedMboxCopyForSent -SourceMailbox <String[]>
ParameterTypeDescriptionRequiredDefault
SourceMailbox (Identity)String[]Shared mailbox(es). Pipeline accepted.Yes-

Example

Set-SharedMboxCopyForSent -SourceMailbox 'sharedmailbox@contoso.com'

Test-SharedMailboxCompliance

Report shared mailbox sign-in activity and Exchange Online licensing indicators.

Syntax

Test-SharedMailboxCompliance [-GridView]
ParameterTypeDescriptionRequiredDefault
GridViewSwitchShow output in Out-GridView (default behavior). Use -GridView:$false to return objects.NoTrue

Example

Test-SharedMailboxCompliance