HOW TO: Create Lync Server Custom, Scalable Voice Dial Plans – Part 2 (Scripts)

In a previous Unified Communications blog, I outlined a design to facilitate end user dialing habits across multiple offices.  The design called for 4, 7, & 10 digit dialing levels.  In order to scale this solution, I helped my client automate the deployment of new office locations and maintain existing Lync dial plans.  The following scripts will help propagate changes throughout the Lync infrastructure.  This may not work immediately for your environment, but the structure is in place to help you scale your Lync infrastructure and provide a custom user experience at every office.


  1. Define the new Office 7 Digit extension range in _Base-NA-7Digit Dial Plan
  2. Execute the New-OfficeDialPlan.ps1
  3. Customize the new office dialplan’s Operator and 4 Digit extension range
  4. After hours, Execute the Update-OfficeDialPlans.ps1


Step 1

Using the Lync Control Panel, add the newest office to the default 7 digit dial plan to ensure that the new DID range is added to all office dial plans.  This will ensure that the inter-office dial habits are maintained when this new office is online.

Step 2

The New-OfficeDialPlan.ps1 is designed to create a new dial plan for the new branch office using the existing normalization rules within the _Base dial plans.  You will be prompted to answer a few basic questions about the site for description purposes. 


# Run the program from Lync Powershell by typing .\New-OfficeDialPlan.ps1.

Write-Host -ForegroundColor red (“Have you updated the _Base-NA-7Digit Dial Plan with the new office’s DID range?  If not, press Ctrl + C.”)

$SiteID=Read-Host “Enter the new Site ID”

$City=Read-Host “Enter the City”

$State=Read-Host “Enter the State (i.e. TX)”

$Operator=Get-CsVoiceNormalizationRule -Filter _Base-NA-Oper*

$4Digit=Get-CsVoiceNormalizationRule -Filter _Base-NA-4Digit*

$7Digit=Get-CsVoiceNormalizationRule -Filter _Base-NA-7Digit*

$PSTN=Get-CsVoiceNormalizationRule -Filter _Base-NA-PSTN*

Write-Host ‘Creating New Dial Plan’

New-CSDialPlan $SiteID -Description ($SiteID + ” – ” + $City + “, ” + $State) -City $City -State $State -DialinConferencingRegion ‘Global’

$NormRuleToDelete = Get-CSVoiceNormalizationRule $SiteID

Remove-CSVoiceNormalizationRule $NormRuleToDelete.Identity -ErrorAction:SilentlyContinue

Write-Host ‘Creating Normalization Rules…’

ForEach ($Rule in $Operator) {New-CsVoiceNormalizationRule -Parent $SiteID -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}

ForEach ($Rule in $4Digit) {New-CsVoiceNormalizationRule -Parent $SiteID -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}

ForEach ($Rule in $7Digit) {New-CsVoiceNormalizationRule -Parent $SiteID -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}

ForEach ($Rule in $PSTN) {New-CsVoiceNormalizationRule -Parent $SiteID -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}

Write-Host -Foregroundcolor green ‘COMPLETE’

Write-Host -Foregroundcolor green ‘Summary of new Dial Plan:’

Get-CsDialPlan $SiteID

Write-Host -Foregroundcolor yellow (‘Make sure to update the Operator & 4 Digit Rules for this new Dial Plan ‘ + $SiteID)

Step 3

After the new office dial plan has been created, you must customize the Operator and 4 Digit routing.  Likely when dialing 0 within the new office, the call will need to be routed to the reception user or response group.  Additionally, you must define the 4 digit normalization rule to enable intra-site dialing habits.  The 7 Digit, 10/11 Digit, and International normalization rule will have been imported during creation.

Step 4

Now that the new office is fully deployed, we should update all of the other sites’ 7 Digit normalization rules to include the newest office and extension range.  The Update-OfficeDialPlans.ps1 script will first remove all the 7 Digit & PSTN normalizations rules, then import the latest defaults from the corresponding _Base dial plans.  This process may take considerable time due to the nature of deleting/adding dozens of normalization rules to each dial plan, so I recommend running this one after hours.  Remember that dial plans are downloaded to every client on sign-in, so these changes will not be adopted immediately.

# Run the program from Lync Powershell by typing .\Update-OfficeDialPlans.ps1

$SiteDialPlans=Get-CSDialplan | Where-Object {$_.SimpleName -like ‘Site*’ }
$Base7Digit=Get-CsVoiceNormalizationRule -Filter _Base-NA-7Digit*
$BasePSTN=Get-CsVoiceNormalizationRule -Filter _Base-NA-PSTN*

foreach ($D in $SiteDialPlans)

Write-Host -ForegroundColor yellow ($D.Identity + “: Removing Old 7 Digit & PSTN Normalization Rules”)
$Old7Digit = Get-CsVoiceNormalizationRule -Filter ($D.Identity + ‘/7*’ )
foreach ($Rule in $Old7Digit)
    {    Remove-CSVoiceNormalizationRule -Identity $Rule.Identity   }  
$OldPSTN = Get-CsVoiceNormalizationRule -Filter ($D.Identity + ‘/NA-*’)
foreach ($Rule in $OldPSTN)
    {    Remove-CSVoiceNormalizationRule -Identity $Rule.Identity   }

Write-Host -ForegroundColor green ($D.Identity + “: Adding Base Plan 7 Digit & PSTN Normalization Rules”)   
ForEach ($Rule in $Base7Digit) {New-CsVoiceNormalizationRule -Parent $D.Identity -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}
ForEach ($Rule in $BasePSTN) {New-CsVoiceNormalizationRule -Parent $D.Identity -Name $Rule.Name -Description $Rule.Description -Pattern $Rule.Pattern -Translation $Rule.Translation -IsInternalExtension $Rule.IsInternalExtension | Out-Null}



This solution was very rewarding for me, as it allowed me to explore the business problem of enabling new office branches quickly, while providing a standard, but localized, user experience.  My client has been extremely happy with the scripts over the past year.  I hope that this has helped you plan for large rollouts of Lync Voice at your company.  Shoot me a note if you would like to discuss your project in detail.


The script relies on deleting and adding many object on each dial plan.  I am confident that there is a more efficient method of inserting a normalization rule into the middle of the list, but I have been able to locate it. 

If you have any tips, send it over.  I’d love to hear your feedback.


If you are in the Dallas area please join me at the next Unified Communications User Group (UCUG) meeting at the Microsoft campus.  Details are posted on MeetUp.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s