How to Configure Teams Inbound Exempt Number Patterns in PowerShell Using CsInboundExemptNumberPattern

In Microsoft Teams Phone, tenant administrators frequently configure inbound call blocking rules (via CsInboundBlockedNumberPattern) or enable automated carrier spam filtering to block malicious spoofed calls and telemarketing. However, broad regular expression rules or carrier heuristics can inadvertently block critical inbound communications from trusted vendors, partner PBXs, or local emergency services. To prevent false positives, Microsoft Teams PowerShell provides the CsInboundExemptNumberPattern cmdlets, which establish high-priority exemption patterns that always bypass tenant inbound call blocking.

Understanding Inbound Call Screening Precedence in Teams Phone

When an incoming Public Switched Telephone Network (PSTN) call reaches Microsoft Teams Phone System, the signaling stack evaluates the caller’s telephone number against tenant policies in the following strict order:

  1. Tenant Exemption List (CsInboundExemptNumberPattern): If the calling number matches an active exempt pattern regex, screening stops immediately and the call is routed to the destination user, call queue, or auto attendant.
  2. Tenant Block List (CsInboundBlockedNumberPattern): If not exempted, the number is checked against tenant-defined block patterns. Matches are rejected with busy tones or routed to voicemails based on tenant routing rules.
  3. Carrier / Platform Spam Filtering: If no tenant rules match, default automated spam score heuristics apply.

Connecting to Microsoft Teams PowerShell

Launch PowerShell with administrative privileges and sign into your Microsoft 365 tenant using an account assigned the Teams Administrator or Global Administrator role:

Install-Module -Name MicrosoftTeams -Force -AllowClobber
Import-Module MicrosoftTeams
Connect-MicrosoftTeams

Auditing Existing Inbound Exempt Number Patterns

Before adding new exemption entries, list all currently configured exempt rules to inspect pattern syntax and existing scope:

Get-CsInboundExemptNumberPattern | Select-Object Identity, Description, Pattern

To view detailed properties of a specific exemption rule:

Get-CsInboundExemptNumberPattern -Identity "EmergencyPartnerExemption" | Format-List

Creating Inbound Exempt Number Patterns

The New-CsInboundExemptNumberPattern cmdlet requires three parameters:

  • -Identity: A unique, human-readable identifier for the rule.
  • -Pattern: A regular expression (regex) matching the incoming E.164 phone number.
  • -Description: A detailed explanation of why the number or range is exempt from screening.

1. Exempting a Single Specific Phone Number

To exempt a critical partner number (e.g., +44 20 7946 0991):

New-CsInboundExemptNumberPattern -Identity "KeyVendorHelpdesk" -Pattern "^\+442079460991$" -Description "Exempt external vendor dispatch line from inbound spam filters"

2. Exempting an Entire Organizational Number Range

If a partner enterprise operates an entire Direct Inward Dialing (DID) block (such as +1 425 555 0100 through +1 425 555 0199), define a regex pattern matching the prefix:

New-CsInboundExemptNumberPattern -Identity "PartnerBranchDIDBlock" -Pattern "^\+142555501\d{2}$" -Description "Exempt all DIDs from regional hospital branch"

3. Exempting Toll-Free Customer Lines

To allow inbound calls from any UK toll-free 0800 prefix:

New-CsInboundExemptNumberPattern -Identity "UKTollFreeExemption" -Pattern "^\+44800\d{6,7}$" -Description "Allow critical toll-free support callbacks"

Modifying and Testing Exempt Number Patterns

If a regex pattern needs revision or an updated description, use Set-CsInboundExemptNumberPattern:

Set-CsInboundExemptNumberPattern -Identity "KeyVendorHelpdesk" -Pattern "^\+44207946(0991|0992)$" -Description "Updated to include secondary vendor failover line"

Testing Regex Patterns Against Sample Numbers

Before committing patterns in production, validate regex logic against test phone numbers directly within PowerShell using the -match operator:

$testNumber = "+442079460991"
$pattern = "^\+44207946(0991|0992)$"
if ($testNumber -match $pattern) {
    Write-Output "Pattern correctly matches $testNumber"
} else {
    Write-Warning "Pattern failed to match target number"
}

Removing Obsolete Exemption Patterns

When an external vendor relationship ends or temporary emergency lines are decommissioned, remove outdated rules using Remove-CsInboundExemptNumberPattern:

Remove-CsInboundExemptNumberPattern -Identity "TemporaryContractorRange" -Confirm:$false

Monitoring Exemption Routing in Teams Call Quality Dashboard

Following rule deployment, policy replication typically takes up to 30 minutes across Microsoft Teams Phone infrastructure. To verify that exempt calls successfully bypass tenant block rules:

  1. Open the Microsoft Teams Admin Centre (admin.teams.microsoft.com).
  2. Navigate to Voice > Call Quality Dashboard or review real-time PSTN call analytics under user call history.
  3. Verify that calls originating from the exempted number show successful PSTN gateway connection and normal termination without \”Blocked by Tenant Policy\” disconnect codes.

Implementing targeted exempt number patterns in PowerShell provides enterprise voice administrators with precise control over call ingress, ensuring vital business and emergency phone lines remain accessible while preserving aggressive perimeter spam defenses.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.