One of the nicest features released this year for Skype for Business Online is the ability to create normalization rules and group them into dial plans. Normalization rules allow replicating behavior from legacy PBXs, such as extension dialing. It can also accommodate other dialing habits, such as 7-digit dialing for local calls. Right now, administration of normalization rules is only available through PowerShell (expected to change any day now with the release of a new Skype and Teams admin portal). But what if you create your rules and make a mistake? Don’t worry, it’s an easy fix, let’s go over it.

First, here is my current global dial plan with two rules, one for 7 Digit Local Dialing and another for 4 Digit Dialing:

What I want to change is the 4 Digit Dialing normalization rule. Instead of allowing any 4 digits, I want the group of 4 digits to start with a 5 by modifying the matching Pattern. Here’s a better look at the normalization rules:

Use the following command to save the current normalization rules into a variable:

$normRules = (Get-CsTenantDialPlan -Identity Global).NormalizationRules

In our variable $normRules will be the list of normalization rules in an array. We can access the 4 Digit Dialing rule by referring to it using an index of [1] in the array (cue the “arrays start at 1” memes). If you didn’t know, arrays start at 0, so the 7 Digit Local Dialing rule is actually [0], and each subsequent rule increases the index number by 1. By referencing index [1], this allows us to manipulate the Pattern only for the 4 Digit Dialing rule:

You can see the changes in the Pattern and Translation fields at the top and bottom of the screenshot. Once the $normRules variable is update, it can be used to overwrite the existing NormalizationRules field for the Global dial plan:

This method will allow you to make changes to your normalization rules without removing and recreating all of them inside the dial plan, which could be tedious if you have quite a few. Here are all the commands used to make these changes:

$normRules = (Get-CsTenantDialPlan -Identity Global).NormalizationRules
$normRules[1].Pattern = '^5(\d{3})$'
$normRules[1].Translation = '+14051235$1'
Set-CsTenantDialPlan -Identity Global -NormalizationRules $normRules
(Get-CsTenantDialPlan -Identity Global).NormalizationRules

Another scenario is adding a normalization rule to an existing list of rules. This gets a bit trickier, and the best way I found is to create an array whose size can be changed dynamically. This is done when creating the variable $currentRules by specifying it as an [System.Collections.ArrayList] type. If you simply assign it as an [array] type, then when you try to add a new rule, you’ll get an error stating the collection was of a fixed size.

Next, create the new rule using the New-CsVoiceNormalizationRule with the pattern and translation information. Once the rule is created, I put the rule in between the two by using the Insert method followed by the array index and new rule variable name. If you simply wanted to add the rule to the end, you should be able to use the Add method (correction: the Add method does not work!).

Finally, using the same technique above, I set the dial plan with the new normalization rules. Check out the sequence below:

Commands to make these changes:

[System.Collections.ArrayList]$currentRules = (Get-CsTenantDialPlan -Identity Global).NormalizationRules
$NewNormRule = New-CsVoiceNormalizationRule -Parent Global -Description "5 Digit Extension Dialing" -Pattern '^(\d{5})$' -Translation '+140598$' -Name "5DigitExtDialing" -IsInternalExtension $false -InMemory
$currentRules.Insert(1,$NewNormRule)
Set-CsTenantDialPlan -Identity Global -NormalizationRules $currentRules

Removing a rule roughly follows the same steps. You don’t need to save the current rules in a special array to invoke the Remove method along the $currentRules variable and index of the rule to remove. I’m going to remove the 5 digit rule I just added:

$currentRules = (Get-CsTenantDialPlan -Identity Global).NormalizationRules
$currentRules.Remove($currentRules[1])
Set-CsTenantDialPlan -Identity Global -NormalizationRules $currentRules