Skype for Business Addressbook Normalization

The use of regular expressions for dialling and address book normalization have been long been established in the Microsoft Communications product line, but they are not always the easiest rules to construct and then test, especially when doing more advanced manipulation.

Lync 2010 introduced the dialling rule builder in the Control Panel which would construct basic regex rules for you as well as provide a method for testing them (along with the respective powershell commandlets), but the testing of address book normalization has always relied on using Abserver.exe with the -testPhoneNorm switch. Unfortunately, as pointed out by Greig (https://greiginsydney.com/vale-company_phone_number_normalization_rules/) this has been removed in Skype for Business Server 2015  however as he points out there doesn’t seem to be any test-cs commandlet to actually test these rules unlike for voice routing.

Additionally, as blogged by Ken Lesko (http://ucken.blogspot.co.uk/2015/05/skype4b-address-book-normalization.html) the address book normalization rules are now created via powershell rather than saved in the old Company_Phone_Number_Normalization_Rules.txt

So, how do we test these apart from watching the event log and seeing which numbers do not normalize correctly?

Well, I’ve prepared a sample powershell script that will compare a number against all of the normalization rules to see if there is a match, and if there is it will output those details whilst also attempting to apply the transformation so you can see the final normalized number.

Now I’ve only tested this rule against a few simple normalization rules so will be interested in hearing how it works against more complicated rules or if you can refine it but hopefully it provides a little direction on how it could be done.


import-module SkypeForBusiness
$normrules=Get-CsAddressBookNormalizationRule
Write-host "Enter telephone number to check"
$input = read-host
foreach ($rule in $normrules)
{
$testregex=$rule.Pattern
$test = [regex]"$testregex"
if ($test.Match($input).Success -eq "true")
{
$normalizednumber = $input -replace $rule.Pattern,$rule.Translation
write-host ""
Write-host "Priority: "$rule.Priority
Write-host "Name: "$rule.Name
Write-host "Description: "$rule.Description
Write-host "Pattern: "$rule.Pattern
Write-host "Translation: "$rule.Translation
Write-host "Normalized number: " $normalizednumber
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s