Commands › Exchange Online
New-ATPProtectionPolicyRule
Create rules for Microsoft Defender for Office 365 protections 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-ATPProtectionPolicyRule 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 security poli
Quick start script
# New-ATPProtectionPolicyRule — 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-ATPProtectionPolicyRule
$before | Format-List
# 3. Make the change (dry run first)
New-ATPProtectionPolicyRule -Name <String> -SafeAttachmentPolicy <SafeAttachmentPolicyIdParameter> -SafeLinksPolicy <SafeLinksPolicyIdParameter> -WhatIf
New-ATPProtectionPolicyRule -Name <String> -SafeAttachmentPolicy <SafeAttachmentPolicyIdParameter> -SafeLinksPolicy <SafeLinksPolicyIdParameter>
# 4. Verify and diff
$after = Get-ATPProtectionPolicyRule
Compare-Object ($before | Out-String) ($after | Out-String)
Syntax
New-ATPProtectionPolicyRule [-Name] <String> -SafeAttachmentPolicy <SafeAttachmentPolicyIdParameter> -SafeLinksPolicy <SafeLinksPolicyIdParameter>
[-Comments <String>]
[-Confirm]
[-Enabled <Boolean>]
[-ExceptIfRecipientDomainIs <Word[]>]
[-ExceptIfSentTo <RecipientIdParameter[]>]
[-ExceptIfSentToMemberOf <RecipientIdParameter[]>]
[-Priority <Int32>]
[-RecipientDomainIs <Word[]>]
[-SentTo <RecipientIdParameter[]>]
[-SentToMemberOf <RecipientIdParameter[]>]
[-WhatIf]
[<CommonParameters>]
Parameters (14)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.