Others

List Exchange Mailbox Block and Allow Settings with PowerShell

Adam DavisAdam Davis Nov 20, 2026 868 views

Question details

List Outlook on the web junk email settings for user mailboxes using Exchange PowerShell.

List Exchange Mailbox Block and Allow Settings with PowerShell
Product
Microsoft Exchange and Outlook on the web
Device & OS
not provided
Scenario
An Exchange administrator needs to review mailbox block and allow settings without opening each mailbox individually.
Observed behavior
Using a wildcard identity can produce an error when multiple mailboxes match because the command requires a unique mailbox identity.
Before you start

Open an Exchange PowerShell session with permissions to read mailboxes and their junk email configuration. For Exchange Online, connect with Connect-ExchangeOnline; for Exchange Server, use the Exchange Management Shell.

Solution 1Recommended

List junk email settings for all user mailboxes

Use Get-Mailbox to provide individual mailbox identities instead of passing a wildcard directly to the junk email command.

1
Run the mailbox query

In your Exchange PowerShell session, run: Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Get-MailboxJunkEmailConfiguration | Format-List Identity,Enabled,BlockedSendersAndDomains,TrustedSendersAndDomains,TrustedRecipientsAndDomains

2
Review the results

Check Enabled for the junk email setting, then review BlockedSendersAndDomains, TrustedSendersAndDomains, and TrustedRecipientsAndDomains for each mailbox.

Limit an on-premises query to an organizational unit: In Exchange Server, run Get-OrganizationalUnit to find a valid organizational unit, then add -OrganizationalUnit "<Domain name/area>" to Get-Mailbox. Replace the placeholder with the valid unit identity.
Free Microsoft Office alternative

Review exported mailbox reports in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility, making it easy to move and review spreadsheet reports. Exchange PowerShell is still required to retrieve mailbox settings.

Review and organize exported mailbox reports in WPS SpreadsheetsOpen and edit Microsoft Excel XLS and XLSX filesUse a familiar spreadsheet interface for a smooth transitionWork with a free, lightweight Office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does Get-MailboxJunkEmailConfiguration fail with a wildcard identity?

A wildcard can match multiple mailboxes, but the Identity parameter requires a unique mailbox. Pipe results from Get-Mailbox to Get-MailboxJunkEmailConfiguration instead.

How can I see blocked and allowed senders for each mailbox?

Pipe Get-Mailbox results to Get-MailboxJunkEmailConfiguration, then use Format-List with BlockedSendersAndDomains, TrustedSendersAndDomains, and TrustedRecipientsAndDomains.

How do I find mailboxes with junk email filtering disabled?

After retrieving the configurations, use Where-Object { $_.Enabled -eq $false } and display Identity and Enabled with Format-Table.

Can I limit the query to one organizational unit?

In an on-premises Exchange Server session, use Get-OrganizationalUnit to find a valid unit, then add -OrganizationalUnit followed by its identity to Get-Mailbox.