Commands › Exchange Online

Set-MailboxJunkEmailConfiguration

Exchange Online ExchangeOnlineManagement Set-*

Configure the junk email settings on mailboxes.

Quick start script

# Set-MailboxJunkEmailConfiguration — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-ExchangeOnline -CertificateThumbprint $thumb -AppId $appId -Organization $org

# 2. Capture the current state first — you cannot roll back what you never recorded
$before = Get-MailboxJunkEmailConfiguration
$before | Format-List

# 3. Make the change (dry run first)
Set-MailboxJunkEmailConfiguration -Identity <MailboxIdParameter> -WhatIf
Set-MailboxJunkEmailConfiguration -Identity <MailboxIdParameter>

# 4. Verify and diff
$after = Get-MailboxJunkEmailConfiguration
Compare-Object ($before | Out-String) ($after | Out-String)

Syntax

Set-MailboxJunkEmailConfiguration [-Identity] <MailboxIdParameter>
 [-BlockedSendersAndDomains <MultiValuedProperty>]
 [-Confirm]
 [-ContactsTrusted <Boolean>]
 [-DomainController <Fqdn>]
 [-Enabled <Boolean>]
 [-FailOnError <Boolean>]
 [-IgnoreDefaultScope]
 [-SenderScreeningEnabled <Boolean>]
 [-TrustedListsOnly <Boolean>]
 [-TrustedRecipientsAndDomains <MultiValuedProperty>]
 [-TrustedSendersAndDomains <MultiValuedProperty>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (13)

ParameterTypeRequiredWhat it controls
-Identity MailboxIdParameter yes The Identity parameter specifies the mailbox that you want to modify. You can use any value that uniquely identifies the mailbox. For example:
-BlockedSendersAndDomains MultiValuedProperty The BlockedSendersAndDomains parameter specifies the Blocked Senders list, which is a list of sender email addresses and domains whose messages are automatically sent to the Junk Email folder. This parameter...
-Confirm SwitchParameter The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on whether the cmdlet requires confirmation before proceeding.
-ContactsTrusted Boolean The ContactsTrusted parameter specifies whether the contacts in the Contacts folder are treated as trusted senders. This parameter corresponds to the Outlook on the web setting: Trust email from my contacts. Valid values are:
-DomainController Fqdn This parameter is available only in on-premises Exchange.
-Enabled Boolean The Enabled parameter enables or disables the junk email rule on the mailbox (a hidden Inbox rule named Junk E-mail Rule). Valid values are:
-FailOnError Boolean This parameter is available only in the cloud-based service.
-IgnoreDefaultScope SwitchParameter The IgnoreDefaultScope switch tells the command to ignore the default recipient scope setting for the Exchange PowerShell session, and to use the entire forest as the scope. You don't need to specify a value with this switch.
-SenderScreeningEnabled Boolean This parameter is available only in the cloud-based service.
-TrustedListsOnly Boolean The TrustedListsOnly parameter specifies that only messages from senders in the Safe Senders list are delivered to the Inbox. All other messages are treated as junk email. This parameter corresponds to the Outlook on...
-TrustedRecipientsAndDomains MultiValuedProperty This parameter is reserved for internal Microsoft use.
-TrustedSendersAndDomains MultiValuedProperty The TrustedSendersAndDomains parameter specifies the Safe Senders list and Safe Recipients list, which are lists of email addresses and domains. Messages from these senders that reach the mailbox are never delivered...
-WhatIf SwitchParameter The WhatIf switch shows what the command does without making any changes. You don't need to specify a value with this switch.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.