Guide to Powershell Commands for Direct Routing (Teams SBC to Microsoft 365) v13.7

Guide to Powershell Commands for Direct Routing (Teams SBC to Microsoft 365) v13.7

Introduction

SIP Manager is used to place an order and start the configuration. If you have completed 1-5 steps of ‘SIP Manager Purchase and Configuration’ guide and you are at the point where you need to execute PowerShell commands manually, this guide explains how to associate user and resource accounts using PowerShell commands.

Adding User and Resource Accounts

Assumptions

1.    You have the latest version of PowerShell installed on the administration machine (using an older version of Powershell is likely to cause delays/prevent the configuration from being successful).  

2.     You have a Teams Admin account that has full access to the Teams role

·       To get the admin logon details:

$credential = Get-Credential

3.     You have the Microsoft Teams PowerShell connector installed  

o   To use the Micorsoft Teams Connector:

Install-Module MicrosoftTeams

Stage 1. Initiate PowerShell Connection

Create a connection to Microsoft Teams from within PowerShell. Running the code below will initiate the required module, set execution permissions, and complete the connection. You will be asked to sign-in to Microsoft during this process, and perform Two Factor Authentication, if required on your account.

-        If you are using Teams PowerShell Module 1.1.6

Import-Module MicrosoftTeams

$credential = Get-Credential

$sfbSession = New-CsOnlineSession -Credential $credential

Import-PSSession $sfbSession

-        If you are using Teams PowerShell Module 2.0 or later

Import-Module MicrosoftTeams

$credential = Get-Credential

Connect-MicrosoftTeams -Credential $credential

 

Stage 2. Enable User(s) for Calling

For each user, make sure they have the correct license. Then, run the following command (per user) to enable calling for them.

Powershell> Set-CsUser -Identity <User name> -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:<E.164 Tel Number>

Important - When adding each number, prefix it in e164 format (e.g. +441232134567).  If you don’t, calls will fail.

NB - You can only use the phone numbers supplied by Jola Reseller with your Teams SBC account. 

Repeat the above steps for each user in your organisation


Stage 3. Configure PSTN Usage

We’re going to create a PSTN Usage called “All”. This will be the policy we use for routing all calls between Jola SBC and Teams.

Powershell> Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="All"}


Stage 4. Configure Online Voice Routing

We’re going to define how calls are routed using a match (regular expression). To ensure all calls are passed to Jola Teams SBC, we’re going to make our Route match any digits dialled.

Powershell> New-CSOnlineVoiceRoute -Identity “All" -NumberPattern ".*" -OnlinePstnGatewayList <SBC FQDN> -Priority 1 -OnlinePstnUsages "All"


Stage 5. Create Online Voice Routing Policy

This step now links our voice route and Usages.

Powershell> New-CSOnlineVoiceRoutingPolicy "CallAnywhere" -OnlinePstnUsages "All"


Stage 6. Grant Voice Routing Policy to User or Resource

Now we can link our Voice Routing Policy to a user.

Powershell> Grant-CsOnlineVoiceRoutingPolicy -Identity <User> -PolicyName “CallAnywhere”

The same command can be applied to grant Voice Routing Policy to a resource.

Powershell> Grant-CsOnlineVoiceRoutingPolicy -Identity <Resource> -PolicyName “CallAnywhere”

 

Repeat this step for each user in your Organisation.

***PLEASE NOTE*** 

1.     It can take up to an hour before you are able to run the Stage 5 command after completing Stage 4.

2.     Once you have successfully run the stage 5 command it can take up to 48 hours for the user to be able to make and/or receive calls.  This is a known Microsoft issue that they are working to improve. 

During this 48 hour period:

·       The user may be able to make but not receive calls (or vice versa).  

·       They may temporarily be able to make or receive calls and then lose this facility.

 

To check for errors in the config (i.e. to check whether call issues in this 48 hour period are due to the propagation delay and not config errors) you are able to run the following PowerShell command:

Get-CsOnlineUser -Identity <Username>

 

Use the above command if inbound calls only are failing. The response will be as follows i.e. the correct number for the user in question in the e164 format.

OnPremLineURI                        : tel:+44xxxxxxxxxx


Stage 7. Configure your Resource Account Number

Things to be aware of when running this command

1. This command is only needed if configuring Resource accounts (i.e. Auto Attendants / Call Queues).  It is NOT needed when setting up User accounts.
2. The Resource Account(s) must have the Virtual Phone System License

Set-CsOnlineApplicationInstance -Identity <Resource Username> -OnpremPhoneNumber +<Number>


Common Issues and troubleshooting command Lines

Issue: Cannot use the "customer.teams.sipmanager.co.uk" domain as it was not configured for this tenant.

This is often caused by issues with the domain setup. 

1.     Ensure the sub domain is listed in your Office 365 account, and Setup is Complete.

2.     Ensure one user is assigned to the sub domain (see link below). Ensure that user has a license. This can be removed after setup.

Please see: https://docs.microsoft.com/en-us/microsoftteams/direct-routing-sbc-multiple-tenants

 

·       Issue: Policy "CallAnywhere" is not a user policy. You can assign only a user policy to a specific user.

Note: This is a common error, and simply down to a propagation delay in Office 365. Give it an hour 



Adding new Users / Resources to a live tenant

When you have a live tenant you are able to make changes to the tenant in the  ‘TEAMS’ section > ‘MANAGE TENANTS’ sub-section in  SIP Manager. Please see separate guide in Knowledgebase for more information on the ‘MANAGE TENANTS’ section of Mobile Manager for detailed information. 
When the changes have been made in SIP Manager the tenant needs to be configured using Powershell.  The steps to follow are as below.
The ‘Stages’ and ‘Assumptions’ referred to below are those referred to  in the  “Configuring the tenant and adding User and Resource Accounts” section at the top of this guide.

User

1.    All 3 of the assumptions in Section 1 are relevant

2.    Stage 1 needs to be followed

3.    Stage 5 needs to be followed

4.    Enter the details of each user within SIP manager

5.    Click on 'Manual Sync' in SIP Manager

Resource

1.    All 3 of the assumptions in Section 1 are relevant

2.    Stage 1 needs to be followed

3.    Stage 6 needs to be followed

4.    Enter the details of the Resource account in SIP Manager

5.    Click on 'Manual Sync' in SIP Manager

Removing Users from a live tenant

This command removes the User:

Set-CsUser -Identity <User name> -OnPremLineURI $null

 

This command then removes the user policy for calling:

Grant-CsOnlineVoiceRoutingPolicy -Identity <User> -PolicyName $null

Once the commands above have been run remove the user within SIP Manager and click Manual Sync.

 

How to Ensure Connectivity

There are a number of checks we can perform, these should be done either as you configure the Teams tenant, or once the initial configuration has been done.

 

Checking a User has Voice Enabled

To check that a user has voice enabled, go to the Microsoft Teams Admin Center.  In the Users section, select the user that you want to check.

As per the example below, they are voice enabled if they have a phone number and the have the ‘AllowCalling’ policy set in the policies section:

 

Useful Troubleshooting Commandlines

Get-CsOnlineVoiceRoutingPolicy         (Confirms the routing policy is set up correctly)

Get-CsOnlineVoiceRoute             (Confirmes the voice route is configured correctly)

Get-CsOnlineUser -identity <username> | fl *OnPrem*            (Confirms the user is set up correctly and the number is in the correct format +44)

 

Get-CsOnlineUser -identity <username> | fl *Policy*     (This ensures the user has the correct policies enabled)




    • Related Articles

    • SIP Manager Teams Purchase and Config v3

      Guide to using SIP Manager and the Microsoft 365 Admin Centre to Order and Configure Teams ‘Direct Routing’ There are 8 stages in the Teams Purchase wizard on SIP Manager: 1. Provisioning Pre-Requisites 2. Tenant Details 3. Tenant Details ...
    • Manage Tenants - Direct Routing

      Guide to the ‘MANAGE TENANTS’ sub-section within ‘TEAMS’ on SIP Manager The ‘Manage Tenants’ section is designed to allow you to view and manage your live tenants: Manage the ‘Direct Routing’ Calling Plans and Users that are live on your tenant ...
    • Teams DR Porting

      Teams Number Porting Explained There are a number of stages to porting a number into our Teams Direct Routing product. This guide will explain the process, set expectations for lead times and guides on what to do when the port is accepted. ...
    • Direct Routing - Outbound CLID Configuration

      Setting the Outbound CLID – Direct Routing with Microsoft Teams ​ There currently isn’t a way for this to be configured by customers however this can be forced by changes within the back end of our systems. Forcing the Outbound CLID (Calling Line ID) ...
    • Guide to Jola International Numbering

      Introduction Jola offers international numbering for SIP Trunk and Teams Direct Routing services. We cover provisioning and numbering in over 180 countries with competitive outbound and inbound calling rates.  Whether you are interested in purchasing ...