Test-CSOnlineUserVoiceRouting: Test a user's Online Voice Routing Policy for Teams Direct Routing


With the preview release of Teams Direct Routing users are now able to make and receive PSTN calls using certified SBCs instead of Calling Plans. Part of setting this up involves setting up PSTN Usages, Voice Routes, Online Voice Routing Policies, PSTN Gateways etc. within Skype Online PowerShell.

Much like Skype for Business, if your users have multiple calling requirements the amount of Voice Routes, PSTN Usages etc. can grow quickly and sometimes make it quite hard to fathom how a call will route. With Skype for Business Control Panel, you have a handy GUI tool to test the voice routing.

By specifying a dialed number and a user’s SIP address it will test based on the user’s assigned dial plan and policy. On the results, it will show what normalization rule was used and the normalized number. With the number normalized it will then show the first matching PSTN Usage and Route.

Like I say, if you have a complex voice routing scenario, this tool is great for quickly troubleshooting and making sure calls are routing where you intend them to go.

As all of Direct Routing’s configuration is done in PowerShell it’s quite hard to visualise this.

Introducing Test-CSOnlineUserVoiceRouting

I’ve written a quick script to essentially do that. You need to specify a user to test as and a dialed number. For example, the below would testing the routing for user@domain calling 01234567890:

.\Test-CSOnlineUserVoiceRouting.ps1 -User [email protected] -DialedNumber 01234567890

The first thing the script will do is normalise the dialed number using the user’s “Effective Tenant Dial Plan” using Get-CsEffectiveTenantDialPlan and Test-CsEffectiveTenantDialPlan. This get’s the user’s effective normalisation rules and puts the number through it.

The script then grabs the user’s assigned OnlineVoiceRoutingPolicy. It will then gather all associated PSTN Usages to that policy. Once it has all that, it will go through each PSTN Usage (in the order they are assigned in the policy) and look for a matching Voice Route.

Once a matching Voice Route is found, it will continue to look for more within that same PSTN Usage. (Currently, once a matching Voice Route is found inside a PSTN Usage, all remaining PSTN Usages are ignored).

Finally, in priority order, it will list all routes found and associated PSTN Gateways (SBCs).

Note: The PSTN Gateway order is irrelevant as they are used in “round robin” order.

One final point to make, this doesn’t take into account if the user has a Calling Plan too (or indeed a CCE). In that scenario, a Calling Plan is used as a last resort after Direct Routing.

This is the script returning a list of matching Voice Routes:

This is the script unable to find a Voice Route to use:

Hope this is useful. All feedback welcome.

The script can be downloaded from GitHub.