Commands › Exchange Online

New-HostedOutboundSpamFilterRule

Exchange Online ExchangeOnlineManagement New-*

Create outbound spam filter rules in your cloud-based organization.

Quick start script

# New-HostedOutboundSpamFilterRule — 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-HostedOutboundSpamFilterRule
$before | Format-List

# 3. Make the change (dry run first)
New-HostedOutboundSpamFilterRule -Name <String> -HostedOutboundSpamFilterPolicy <HostedOutboundSpamFilterPolicyIdParameter> -WhatIf
New-HostedOutboundSpamFilterRule -Name <String> -HostedOutboundSpamFilterPolicy <HostedOutboundSpamFilterPolicyIdParameter>

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

Syntax

New-HostedOutboundSpamFilterRule [-Name] <String> -HostedOutboundSpamFilterPolicy <HostedOutboundSpamFilterPolicyIdParameter>
 [-Comments <String>]
 [-Confirm]
 [-Enabled <Boolean>]
 [-ExceptIfFrom <RecipientIdParameter[]>]
 [-ExceptIfFromMemberOf <RecipientIdParameter[]>]
 [-ExceptIfSenderDomainIs <Word[]>]
 [-From <RecipientIdParameter[]>]
 [-FromMemberOf <RecipientIdParameter[]>]
 [-Priority <Int32>]
 [-SenderDomainIs <Word[]>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (13)

ParameterTypeRequiredWhat it controls
-Name String yes The Name parameter specifies a unique name for the outbound spam filter rule. The maximum length is 64 characters. If the value contains spaces, enclose the value in quotation marks (").
-HostedOutboundSpamFilterPolicy HostedOutboundSpamFilterPolicyIdParameter yes The HostedOutboundSpamFilterPolicy parameter specifies the outbound spam filter policy that's associated with the outbound spam filter rule.
-Comments String The Comments parameter specifies informative comments for the rule, such as what the rule is used for or how it has changed over time. The length of the comment can't exceed 1024 characters.
-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.
-Enabled Boolean The Enabled parameter specifies whether the rule is enabled. Valid values are:
-ExceptIfFrom RecipientIdParameter[] The ExceptIfFrom parameter specifies an exception that looks for messages from specific senders. You can use any value that uniquely identifies the sender. For example:
-ExceptIfFromMemberOf RecipientIdParameter[] The ExceptIfFromMemberOf parameter specifies an exception that looks for messages sent by group members. You can use any value that uniquely identifies the group. For example:
-ExceptIfSenderDomainIs Word[] The ExceptIfSenderDomainIs parameter specifies an exception that looks for senders with email address in the specified domains. You can specify multiple domains separated by commas.
-From RecipientIdParameter[] The From parameter specifies a condition that looks for messages from specific senders. You can use any value that uniquely identifies the sender. For example:
-FromMemberOf RecipientIdParameter[] The FromMemberOf parameter specifies a condition that looks for messages sent by group members. You can use any value that uniquely identifies the group. For example:
-Priority Int32 The Priority parameter specifies a priority value for the rule that determines the order of rule processing. A lower integer value indicates a higher priority, the value 0 is the highest priority, and rules can't...
-SenderDomainIs Word[] The SenderDomainIs parameter specifies a condition that looks for senders with email address in the specified domains. You can specify multiple domains separated by commas.
-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.