Commands › Exchange Online

New-TeamsProtectionPolicyRule

Exchange Online ExchangeOnlineManagement New-*

Create Microsoft Teams protection policy rules. **Note**: If the rule already exists (the Get-TeamsProtectionPolicyRule cmdlet returns output), you can't use this cmdlet.

Quick start script

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

# 3. Make the change (dry run first)
New-TeamsProtectionPolicyRule -Name <String> -TeamsProtectionPolicy <TeamsProtectionPolicyIdParameter> -WhatIf
New-TeamsProtectionPolicyRule -Name <String> -TeamsProtectionPolicy <TeamsProtectionPolicyIdParameter>

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

Syntax

New-TeamsProtectionPolicyRule [-Name] <String> -TeamsProtectionPolicy <TeamsProtectionPolicyIdParameter>
 [-Comments <String>]
 [-Confirm]
 [-Enabled <Boolean>]
 [-ExceptIfRecipientDomainIs <Word[]>]
 [-ExceptIfSentTo <RecipientIdParameter[]>]
 [-ExceptIfSentToMemberOf <RecipientIdParameter[]>]
 [-Organization <OrganizationIdParameter>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (10)

ParameterTypeRequiredWhat it controls
-Name String yes The Name parameter specifies the unique name of the Teams protection policy rule. If the value contains spaces, enclose the value in quotation marks. The default name of the Teams protection policy rule in an...
-TeamsProtectionPolicy TeamsProtectionPolicyIdParameter yes The TeamsProtectionPolicy parameter specifies the Teams protection policy that's associated with this rule. The only available policy is named Teams Protection Policy.
-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 This parameter is reserved for internal Microsoft use.
-ExceptIfRecipientDomainIs Word[] The ExceptIfRecipientDomainIs parameter specifies an exception to ZAP for Teams protection that looks for recipients of Teams messages with email addresses in the specified domains. You can specify multiple domains...
-ExceptIfSentTo RecipientIdParameter[] The ExceptIfSentTo parameter specifies an exception to ZAP for Teams protection that looks for recipients of Teams messages. You can use any value that uniquely identifies the recipient. For example:
-ExceptIfSentToMemberOf RecipientIdParameter[] The ExceptIfSentToMemberOf parameter specifies an exception to ZAP for Teams protection that looks for Teams messages sent to members of distribution groups or mail-enabled security groups. You can use any value that...
-Organization OrganizationIdParameter This parameter is reserved for internal Microsoft use.
-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.