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>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String | Target mailbox/recipient. Pipeline accepted. | Yes | - |
MailboxAlias | String | Alias (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]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String | Target mailbox. | Yes | - |
UserMailbox | String[] | One or more principals to grant. Pipeline accepted. | Yes | - |
AccessRights | String | Rights: All, FullAccess, SendAs, SendOnBehalfTo. | No | All |
AutoMapping | Switch | Enable/disable Outlook automapping. | No | False |
PassThru | Switch | Emit detailed permission objects (default shows only confirmation messages). | No | False |
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>]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
RecipientType | String | Recipient type to analyze: User, Shared, Room, or All. | Yes | - |
CsvFolder | String | Destination folder for the CSV. | No | Current directory |
BatchSize | Int32 | Number of processed mailboxes buffered before the CSV is flushed. | No | 25 |
Resume | Switch | Resume from the latest matching CSV or from -CsvPath. | No | False |
CsvPath | String | Explicit CSV file to resume. When omitted, the latest matching CSV is used. | No | - |
MaxConsecutiveErrors | Int32 | Stop after this many consecutive mailbox-level failures. | No | 5 |
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
-Csvand-CsvFolder - automatic CSV export for
-Alland-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
DisplayNameandName - extra CSV fields
UserPrincipalNameandIsMoerain CSV exports
Note:
-Csvis the explicit switch for single-mailbox exports.-Alland-Domainalready export to CSV, so-Csvis optional in those modes.-CsvFoldercontrols the export destination for every CSV-producing mode.-Resumereuses the latest matching CSV in the target folder unless-CsvPathis specified.-BatchSizecontrols how many processed recipients are buffered before the CSV is flushed.-IncludePrimaryOnlykeeps recipients that would otherwise be omitted because they have no secondary aliases.-IncludeMoerakeeps addresses in the tenant'sonmicrosoft.comdomain 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>]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String | Target mailbox/recipient. Pipeline accepted. | Yes in single mode | - |
Csv | Switch | Force CSV export for a single mailbox query. Optional when using -All or -Domain. | No | False |
CsvFolder | String | Destination folder for CSV export. | No | - |
IncludePrimaryOnly | Switch | Include recipients with only a primary SMTP address in CSV exports. | No | False |
IncludeMoera | Switch | Include MOERA addresses in CSV exports. | No | False |
BatchSize | Int32 | Number of processed recipients to buffer before flushing the CSV. | No | 25 |
Resume | Switch | Resume from the latest matching CSV or from -CsvPath. | No | False |
CsvPath | String | Explicit CSV file to resume. When omitted, the latest matching CSV is used. | No | - |
MaxConsecutiveErrors | Int32 | Stop after this many consecutive recipient-level failures. | No | 5 |
All | Switch | Export aliases for all non-guest recipients and write a CSV report. | No | False |
Domain | String | Export 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' -Csvhides the MOERA row and keeps the mailbox only if it has a real secondary alias.Get-MboxAlias -SourceMailbox 'user@contoso.com' -Csv -IncludeMoeraincludes 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]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String | Target mailbox/recipient. Pipeline accepted. | No | - |
IncludeTrace | Switch | Include raw message trace objects in the output. | No | False |
Example
Get-MboxLastMessageTrace -SourceMailbox 'user@contoso.com'
Get-MboxLastMessageTrace -SourceMailbox 'user@contoso.com' -IncludeTrace
Get-MboxPermission
List mailbox permissions.
Syntax
Get-MboxPermission -Identity <String>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
Identity | String | Target 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]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String[] | Target mailbox/recipient. Pipeline accepted. | Yes | - |
Raw | Switch | Return only the PrimarySmtpAddress values. | No | False |
Detailed | Switch | Include additional fields (Identity, RecipientTypeDetails). | No | False |
Get-MboxPrimarySmtpAddress is also available as gpa (alias).
By default, object output is compact and optimized for console readability:
DisplayNamePrimarySmtpAddress
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>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
User (Identity, UserPrincipalName) | String | Target 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.Allscopes are available. - Output includes
LastUserActionTime,LastInteractiveSignIn,LastSeen, and theSourceused.
New-SharedMailbox
Create a shared mailbox.
Syntax
New-SharedMailbox -SharedMailboxSMTPAddress <String> -SharedMailboxDisplayName <String> -SharedMailboxAlias <String>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SharedMailboxSMTPAddress | String | Primary SMTP address of the new shared mailbox. | Yes | - |
SharedMailboxDisplayName | String | Display name. | Yes | - |
SharedMailboxAlias | String | Mail 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>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String | Target mailbox/recipient. Pipeline accepted. | Yes | - |
MailboxAlias | String | Alias (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>]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String | Target mailbox. | Yes | - |
UserMailbox | String[] | Principal(s) to revoke. | Yes (User mode) | - |
AccessRights | String | Rights (e.g., FullAccess, SendAs, SendOnBehalfTo). Defaults to All. | No | All |
ClearAll | Switch | Remove 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>]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
SourceMailbox (Identity) | String[] | Target mailbox(es). Pipeline accepted. | No | - |
Csv | String | CSV file path containing EmailAddress column. | No | - |
Language | String | Culture code (e.g., it-IT, en-US). | No | it-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[]>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
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[]>
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
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]
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
GridView | Switch | Show output in Out-GridView (default behavior). Use -GridView:$false to return objects. | No | True |
Example
Test-SharedMailboxCompliance