Set-MailboxJunkEmailConfiguration

 

Applies to: Exchange Online, Exchange Server 2016

Topic Last Modified: 2017-10-06

This cmdlet is available in on-premises Exchange Server 2016 and in the cloud-based service. Some parameters and settings may be exclusive to one environment or the other.

Use the Set-MailboxJunkEmailConfiguration cmdlet to configure the junk email settings on mailboxes.

noteNote:
You can only use this cmdlet on a mailbox that's been opened in Outlook (in Cached Exchange mode) or Outlook on the web. If the mailbox hasn't been opened, you'll receive the error: The Junk Email configuration couldn't be set. The user needs to sign in to Outlook Web App before they can modify their Safe Senders and Recipients or Blocked Senders lists. If you want to suppress this error for bulk operations, you can add -ErrorAction SlientlyContinue to the end of the command.

Set-MailboxJunkEmailConfiguration -Identity <MailboxIdParameter> [-BlockedSendersAndDomains <MultiValuedProperty>] [-Confirm [<SwitchParameter>]] [-ContactsTrusted <$true | $false>] [-DomainController <Fqdn>] [-Enabled <$true | $false>] [-IgnoreDefaultScope <SwitchParameter>] [-TrustedListsOnly <$true | $false>] [-TrustedRecipientsAndDomains <MultiValuedProperty>] [-TrustedSendersAndDomains <MultiValuedProperty>] [-WhatIf [<SwitchParameter>]]

This example disables the junk email rule configuration for the user named David Pelton.

Set-MailboxJunkEmailConfiguration "David Pelton" -Enabled $false

This example makes the following configuration changes to the safelist collection for the user named Michele Martin:

  • Adds contoso.com and fabrikam.com to the Safe Senders list without affecting other existing entries.

  • Adds jane@fourthcoffee.com to the Blocked senders list without affecting other existing entries.

Set-MailboxJunkEmailConfiguration "Michele Martin" -TrustedSendersAndDomains @{Add="contoso.com","fabrikam.com"} -BlockedSendersAndDomains @{Add="jane@fourthcoffee.com"}

This example identifies mailboxes where contacts are treated as trusted senders, and then changes the junk email configuration to not treat contacts as trusted senders.

Get-MailboxJunkEmailConfiguration * | Where {$_.ContactsTrusted -eq $true} | Set-MailboxJunkEmailConfiguration -ContactsTrusted $false

This cmdlet controls the following junk email settings on the mailbox:

  • Enable or disable the junk email rule   The junk email rule (a hidden Inbox rule named Junk E-mail Rule) controls the delivery of messages to the Junk Email folder or the Inbox based on the SCL Junk Email Folder threshold (for the organization or the mailbox) and the safelist collection on the mailbox. Users can enable or disable the junk email rule in their own mailbox by using Outlook on the web.

  • Configure the safelist collection   The safelist collection is the Safe Senders list, the Safe Recipients list, and the Blocked Senders list. Users can configure the safelist collection on their own mailbox by using Microsoft Outlook or Outlook on the web.

For more information, see Configure Exchange antispam settings on mailboxes.

You need to be assigned permissions before you can run this cmdlet. Although this topic lists all parameters for the cmdlet, you may not have access to some parameters if they're not included in the permissions assigned to you. To find the permissions required to run any cmdlet or parameter in your organization, see Find the permissions required to run any Exchange cmdlet.

 

Parameter Required Type Description

Identity

Required

Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter

The Identity parameter specifies the mailbox that you want to modify. You can use any value that uniquely identifies the mailbox.

For example:

  • Name

  • Display name

  • Alias

  • Distinguished name (DN)

  • Canonical DN

  • <domain name>\<account name>

  • Email address

  • GUID

  • LegacyExchangeDN

  • SamAccountName

  • User ID or user principal name (UPN)

BlockedSendersAndDomains

Optional

Microsoft.Exchange.Data.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 corresponds to the Outlook on the web setting: Move email from these senders or domains to my Junk Email folder.

To enter multiple values and overwrite any existing entries, use the following syntax: <value1>,<value2>.... If the values contain spaces or otherwise require quotation marks, you need to use the following syntax: "<value1>","<value2>"....

To add or remove one or more values without affecting any existing entries, use the following syntax: @{Add="<value1>","<value2>"...; Remove="<value1>","<value2>"...}.

Confirm

Optional

System.Management.Automation.SwitchParameter

The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on if the cmdlet requires confirmation before proceeding.

  • Destructive cmdlets (for example, Remove-* cmdlets) have a built-in pause that forces you to acknowledge the command before proceeding. For these cmdlets, you can skip the confirmation prompt by using this exact syntax: -Confirm:$false.

  • Most other cmdlets (for example, New-* and Set-* cmdlets) don't have a built-in pause. For these cmdlets, specifying the Confirm switch without a value introduces a pause that forces you acknowledge the command before proceeding.

ContactsTrusted

Optional

System.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:

  • $true   Messages from contacts in the Contacts folder that reach the mailbox are never delivered to the Junk Email folder, regardless of the content.

  • $false   Messages from contacts in the Contacts folder aren't treated as trusted senders. The email address is a trusted sender only if it's defined in the Safe Senders list. This is the default value.

DomainController

Optional

Microsoft.Exchange.Data.Fqdn

This parameter is available only in on-premises Exchange 2016.

The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). For example, dc01.contoso.com.

Enabled

Optional

System.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:

  • $true   The junk email rule is enabled in the mailbox. This value corresponds to the Outlook on the web setting: Automatically filter junk email. This is the default value.

    Exchange use the safelist collection of the mailbox (the Safe Senders list, Safe Recipients list, and Blocked Senders list), and the SCL Junk Email folder threshold (for the organization or the mailbox) to deliver messages to the Inbox or the Junk Email folder.

  • $false   The junk email rule is disabled in the mailbox. This value corresponds to the Outlook on the web setting: Don't move email to my Junk Email folder. Exchange doesn't use the safelist collection of the mailbox or the SCL Junk Email folder threshold to deliver messages to the Inbox or the Junk Email folder.

You can view the status of the junk email rule by running either of the following commands to find the Enabled property value:

  • Get-MailboxJunkEmailConfiguration <MailboxIdentity>

  • Get-InboxRule "Junk E-mail Rule" -Mailbox <MailboxIdentity> -IncludeHidden

You use the JunkEmailEnabled parameter on the Set-OwaMailboxPolicy or Set-OwaVirtualDirectory cmdlets to control the availability of the junk email settings in Outlook on the web.

noteNote:
The state of the junk email rule on the mailbox doesn't affect the client-side junk email settings that are available in the Outlook Junk Email Filter. Even when the junk email rule is disabled in the mailbox, Outlook can still move messages to the Junk Email folder. For example, if Outlook determines the message is spam, or the sender is defined in the Blocked Senders list, Outlook can move the message to the Junk Email folder. For more information, see Configure junk email settings in Outlook 2013.

IgnoreDefaultScope

Optional

System.Management.Automation.SwitchParameter

The IgnoreDefaultScope switch tells the command to ignore the default recipient scope setting for the Exchange Management Shell session, and to use the entire forest as the scope. This allows the command to access Active Directory objects that aren't currently available in the default scope.

Using the IgnoreDefaultScope switch introduces the following restrictions:

  • You can't use the DomainController parameter. The command uses an appropriate global catalog server automatically.

  • You can only use the DN for the Identity parameter. Other forms of identification, such as alias or GUID, aren't accepted.

TrustedListsOnly

Optional

System.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 the web setting: Don't trust email unless it comes from someone in my Safe Senders and Recipients list. Valid values are:

  • $true   Only messages from email address or domain entries in the Safe Senders list and the Safe Recipients list are delivered to the Inbox. All other messages are automatically delivered to the Junk Email folder.

  • $false   Messages from other senders, recipients, and domains aren't automatically treated as junk email, and are evaluated individually. This is the default value.

TrustedRecipientsAndDomains

Optional

Microsoft.Exchange.Data.MultiValuedProperty

This parameter is reserved for internal Microsoft use.

TrustedSendersAndDomains

Optional

Microsoft.Exchange.Data.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 to the Junk Email folder, regardless of the content. This parameter corresponds to the Outlook on the web setting: Don't move email from these senders or domains to my Junk Email folder.

To enter multiple values and overwrite any existing entries, use the following syntax: <value1>,<value2>.... If the values contain spaces or otherwise require quotation marks, you need to use the following syntax: "<value1>","<value2>"....

To add or remove one or more values without affecting any existing entries, use the following syntax: @{Add="<value1>","<value2>"...; Remove="<value1>","<value2>"...}.

To empty the list of email addresses and domains, use the value $null.

Notes:

  • All email addresses in the global address list (GAL) are automatically considered as trusted senders, so you don't need to add them to the list.

  • You can't directly modify the Safe Recipients list by using this cmdlet. You use this parameter to modify the Safe Senders list, and the email addresses and domains are synchronized to the Safe Recipients list.

  • Safe domains aren't recognized in Exchange Online and Exchange Online Protection. For more information, see Domains on the Outlook Safe Senders list aren't recognized by Exchange Online or Exchange Online Protection.

WhatIf

Optional

System.Management.Automation.SwitchParameter

The WhatIf switch simulates the actions of the command. You can use this switch to view the changes that would occur without actually applying those changes. You don't need to specify a value with this switch.

To see the input types that this cmdlet accepts, see Cmdlet Input and Output Types. If the Input Type field for a cmdlet is blank, the cmdlet doesn’t accept input data.

To see the return types, which are also known as output types, that this cmdlet accepts, see Cmdlet Input and Output Types. If the Output Type field is blank, the cmdlet doesn’t return data.

 
Show: