Commands › Exchange Online
New-EOPProtectionPolicyRule
Create rules for the built-in security features for all cloud mailboxes in preset security policies. The rules specify recipient conditions and exceptions for the protection, and also allow you to turn on and turn off the associated preset security policies. **Note**: Unless you manually removed a rule using the Remove-EOPProtectionPolicyRule cmdlet, we don't recommend using this cmdlet to create rules. To create the rule, you need to specify the existing individual security policies that are associated with the preset security policy. We never recommend creating these required individual secu
Quick start script
# New-EOPProtectionPolicyRule — 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-EOPProtectionPolicyRule
$before | Format-List
# 3. Make the change (dry run first)
New-EOPProtectionPolicyRule -Name <String> -AntiPhishPolicy <AntiPhishPolicyIdParameter> -HostedContentFilterPolicy <HostedContentFilterPolicyIdParameter> -WhatIf
New-EOPProtectionPolicyRule -Name <String> -AntiPhishPolicy <AntiPhishPolicyIdParameter> -HostedContentFilterPolicy <HostedContentFilterPolicyIdParameter>
# 4. Verify and diff
$after = Get-EOPProtectionPolicyRule
Compare-Object ($before | Out-String) ($after | Out-String)
Syntax
New-EOPProtectionPolicyRule [-Name] <String> [-Priority <Int32>] -AntiPhishPolicy <AntiPhishPolicyIdParameter> -HostedContentFilterPolicy <HostedContentFilterPolicyIdParameter> -MalwareFilterPolicy <MalwareFilterPolicyIdParameter>
[-Comments <String>]
[-Confirm]
[-Enabled <Boolean>]
[-ExceptIfRecipientDomainIs <Word[]>]
[-ExceptIfSentTo <RecipientIdParameter[]>]
[-ExceptIfSentToMemberOf <RecipientIdParameter[]>]
[-RecipientDomainIs <Word[]>]
[-SentTo <RecipientIdParameter[]>]
[-SentToMemberOf <RecipientIdParameter[]>]
[-WhatIf]
[<CommonParameters>]
Parameters (15)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.