List Exchange Mailbox Block and Allow Settings with PowerShell
Question details
List Outlook on the web junk email settings for user mailboxes using Exchange 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.
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.
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.
In your Exchange PowerShell session, run: Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Get-MailboxJunkEmailConfiguration | Format-List Identity,Enabled,BlockedSendersAndDomains,TrustedSendersAndDomains,TrustedRecipientsAndDomains
Check Enabled for the junk email setting, then review BlockedSendersAndDomains, TrustedSendersAndDomains, and TrustedRecipientsAndDomains for each mailbox.
Find user mailboxes with junk email filtering disabled
Use this filtered query when you only need to identify mailboxes whose Enabled setting is false.
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.

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.




