During some recent Lync and SfB deployments, there has been a need to add a normalization rule to all existing dial plans or only user dial plans. Of course, the easiest way to add the same normalization rule to multiple dial plans is to script it. So here is the info for the script as well as the script itself:
First create the normalization rule in one of the dial plans. For example, you can create a "Catch All" rule in the Global dial plan that will normalize any number to prepend it with a +. The rule will look like this:
Normalization rule name: Catch All
Pattern to match: ^(\d*)$
Translation pattern: +$1
So the idea is to copy the normalization rule that you just created in the Global dial plan to all the User dial plans that already exist (I will explain later how to copy to All dial plans including Site dial plans later in this post). What the script is doing is getting all dial plans that begin with Tag:. This is how User dial plans are identified. Then it will get the normalization rule settings and copy them into all the User dial plans. Here is the script:
$DialPlans=Get-CSDialplan -Filter Tag:*
$CatchAll=Get-CsVoiceNormalizationRule -Filter "Global/Catch All"
foreach ($D in $DialPlans)
{
Write-Host ("Adding Catch All Normalization Rules to Dial Plan: " + $D.Identity)
ForEach ($Rule in $CatchAll) {New-CsVoiceNormalizationRule -Parent $D.Identity -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}
}
If you didn't create the rule in the Global dial plan but in a User dial plan, you would change the -Filter parameter in the second line of the script to be the name of the dial plan/normalization rule name. If you are not sure how to find that out, run the Get-CsDialplan cmdlet and get the name of the dial plan. For example, a User dial plan will look like this: Tag:NA-HoustonDP. User dial plans start with Tag: while site dial plans start with Site:. Then put a forward slash and the name of the normalization rule in that dial plan. Make sure to put quotes around the whole dialplan/normalizationrule name if you have spaces in the names.
So by default, this script will add this "Catch All" normalization rule to the User dial plans and it will be the last normalization rule in the list of normalization rules. The order can be changed by setting the -Priority parameter. Be careful with this though because if you have a lot of global dial plans, you will need to make sure that it doesn't take precedence over some of the normalization rules it shouldn't. Otherwise, you will have to go into each dial plan and move the rule to the appropriate order.
Also, you can narrow the dial plan selection down to just site dial plans by changing the -Filter parameter on the first line of the script from Tag:* to Site:*. This will choose just the site dial plans to add the number normalization rule. And if you want to add the normalization rule to all dial plans, just remove the -Filter parameter all together.
Hope this helps. Let me know if you have any other questions, comments or issues.