Commands › Exchange Online
New-TeamsProtectionPolicyRule
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)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.