Guide to Powershell Commands for Direct Routing (Teams SBC to Microsoft 365) v15

Guide to Powershell Commands for Direct Routing (Teams SBC to Microsoft 365) v15

Microsoft Teams Direct Routing

Guide with PowerShell Commands

V15



1. Introduction

The following guide explains on how to set up Teams Direct Routing using PowerShell Commands. In order to start the process, you will need to place an order within SIP Manager portal. The steps below will help you understand on how to progress with the order within Microsoft Teams environment as well as PowerShell.

Please follow this guide to configure a Direct Routing for Microsoft Teams to connect to SIP Manager - https://docs.microsoft.com/en-us/microsoftteams/how-to-roll-out-teams 

 

*** PLEASE NOTE*** There are several points in this process where there will be delays (of up to 48 hours) before you are able to proceed to the next stage.  These are highlighted in a red font below. 


2. Prerequisites

2.1 Required Microsoft Licences

In order to integrate Microsoft Teams, you must have the correct licenses.
  • E5 (includes Teams Phone System)
  • E1 & E3 + Microsoft Teams Phone Standard
  • Microsoft Business Basic + Microsoft Teams Phone Standard
  • Microsoft Business Standard + Microsoft Teams Phone Standard
  • Microsoft Business Premium + Microsoft Teams Phone Standard

This add-on license that is known as Microsoft Teams Phone Standard (approximately £6/user/month). This can be obtained from your reseller or Microsoft directly.

If at any point you are struggling to locate this license it can be found by following these steps

  • Navigate to https://admin.microsoft.com and sign-in
  • On the left nav bar – select “Billing” / “Purchase Service”.
  • Click “View Products” under Purchase from Microsoft
  • In the Search all product categories box – Enter “Phone”.

You will see various licenses, but these are the two you will need.

  1. Microsoft Teams Phone Standard (For Users)
  2. Microsoft Teams Phone Resource Account (For Auto Attendants & Queues)

Please note: You cannot setup Teams Phone System integration using trial accounts as these trial licenses include a Microsoft calling plan trial which can’t be removed.

Once all users have the correct licenses you can carry on following this guide.


2.2 Provisioning

  1. You have a tenant created on Microsoft that has got Teams and Skype of Business
    DNS Configured.
  1. Your Microsoft Teams tenant’s Coexistence Mode is set to “Teams Only” and not Islands mode. N.B. This change may impact your tenant’s ability (for a short time) to communicate with other tenants.
  1. You have at least one user with the Phone system licence.
  1. Teams has been used by one of those users (to ensure Teams is configured in Azure AD correctly)
  1. You have an unused Microsoft 365 licence that can be used during the initial configuration, After the initial configuration has been completed, this licence can be recycled and assigned to a user.
  1. You have provided us with your domain name.
It is your responsibility to make sure that all prerequisites have been met before proceeding.

3. Setting up the Domain in MS 365

The first step for teams integration is to connect the assigned FQDN this unique domain will be created on our platform and sent to the global administrator to proceed with the next steps.
Login to MS 365 Admin Centre with global admin credentials.
Then click show all > Settings > Domains.
Add a new Domain.

Add the domain name you have been provided with then click Use this domain.


This next stage is very important, click continue with add a txt record highlighted but on the next screen DO NOT click verify.


*** PLEASE NOTE*** Before you click verify you need to send your service provider the TXT name & TXT value so they can add the records to the system, once this is complete and the service provider has confirmed records have been added you can go ahead and click verify.  


Once successfully verified you should see the screen below, untick Exchange and Exchange Online protection this is not needed and will cause issues it is ticked in default.


Now this is complete you should have successfully connected you domain. 



4. Activating your domain

The next step is to activate the domain to allow communication between platforms this is done by activating a user on the subdomain, please follow these steps.
Go to users > Active users and add a new user.


When you create a user, it doesn’t have to be anything special just have the required MS licence and be on the correct domain, passwords aren’t important as nobody will ever have to log in as this user. Click next when all the info has been added.



Select an unused MS licence, once the user has been added the domain is active this user can be deleted and the license can be recycled, Click next once complete.



Optional setting – no entry is needed on this page so just click next.

Review and finish – Double check the info on the screen and click finish adding to complete the process.

***PLEASE NOTE*** It can take several hours for the activation of the subdomain to be processed by Office365. You will not be able to proceed with Stage 2 (below) until this has completed. For reference, see: https://docs.microsoft.com/en-us/microsoftteams/direct-routing-sbc-multiple-tenants 

5. Setting up Windows PowerShell

Assumptions

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).   
You have a Teams Admin account that has full access to the Teams role. 
Install the PowerShell Module for Microsoft Teams, as per the guide from Microsoft below. 

Before you can run PowerShell Commands you need to install the module to communicate with Teams

To find your PowerShell app use the search bar on your desktop once found always run as an administrator or you may run in to issues later.



Installing MicrosoftTeams module

Paste the below commands into PowerShell.

Install-Module -Name MicrosoftTeams 


Type 'Y' if prompted to during the installation


Once you have installed all the module you can run the below command to check to check that they are installed

Get-InstalledModule



Login to your 365 tenant and start a session using the below commands.
Import-Module MicrosoftTeams
Connect-MicrosoftTeams

Log in with a user who has global admin access.
  


Now you’re logged in you can start configuring your teams tenant using PowerShell.

6. System PowerShell Commands

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.

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

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 the correct Teams SBC, we’re going to make our Route match any digits dialled.

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

Create Online Voice Routing Policy
This step now links our voice route and Usages.

New-CSOnlineVoiceRoutingPolicy "CallAnywhere" -OnlinePstnUsages "All"

7. User & Resources Setup & Commands

Enable Phone Services For Users & Resources

Theses commands must be repeated for each user & resource.

7.1 Users

Set-CsPhoneNumberAssignment -Identity "<User name>" -PhoneNumber "<E.164 Tel Number>" -PhoneNumberType DirectRouting

Example:

Set-CsPhoneNumberAssignment -Identity teamstest@87kfyq.onmicrosoft.com -PhoneNumber +441332315901 -PhoneNumberType DirectRouting

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

Example:

Grant-CsOnlineVoiceRoutingPolicy -Identity teamstest@87kfyq.onmicrosoft.com -PolicyName “CallAnywhere”

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.

7.2 Resource Accounts

Creating a Resource account

Login to Microsoft teams admin centre and navigate to Voice > Resource accounts here you

can build auto attendants & call queues.

Click add and create resource accounts for your desired services.
 


Now you need to add this license to your new resource user, navigate to Active users > search for your user and click on the name to access the account details.

Add the Microsoft Teams Phone Resource Account license to your user and save, do this for all resource accounts that will need a telephone number assigning.


Configuring Auto attendants & Call Queues.

Navigate to Call Queues or Auto attendants which is located under the voice section within the teams admin centre, click add and fill in all the sections to your systems specifications



PowerShell Commands for Resource Accounts needing a CLI

 This command is only needed if configuring Resource accounts and needs to be repeated for every resource (i.e., Auto Attendants / Call Queues). 

Set-CsPhoneNumberAssignment –Identity "<User name>" -PhoneNumber "<E.164 Tel Number>" -PhoneNumberType DirectRouting

(Example)

Set-CsPhoneNumberAssignment -Identity AA@uc-support.co.uk -PhoneNumber +441332315900 -PhoneNumberType DirectRouting

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

(Example)

Grant-CsOnlineVoiceRoutingPolicy -Identity AA@uc-support.co.uk -PolicyName “CallAnywhere”

 

***PLEASE NOTE*** 
  It can take up to an hour before you are able to run the command after completing.
Once you have successfully run all the commands 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.

LineURI                       : tel:+44xxxxxxxxxx

7.3 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 SIP Manager for detailed information, available here: https://support.jola.co.uk/portal/en/kb/articles/sip-manager-guide-to-manage-tenants. 

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
o   Stage 7.1 needs to be followed
o   Enter the details of each user within SIP manager
o   Click on 'Manual Sync' in SIP Manager

Resource
o   Assumptions Section 1 to 6 have been completed.
o   Stage 7.2 needs to be followed
o   Enter the details of the Resource account in SIP Manager
o   Click on 'Manual Sync' in SIP Manager

7.4 Removing Users from a live tenant

There have been recent changes to the commands required for removing a user from a phone number. The below command now handles this:

Remove-CsPhoneNumberAssignment -Identity <User name> -RemoveAll

Unassigning the phone number from the User or Resource account will automatically set ‘EnterpriseVoiceEnabled’ to False. The phone number will continue to be available in the tenant.

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

7.5 Disable Voice Mail from an existing user

Voicemail is now applied to Teams Users by default. If you need to disable this, please run the below command.

Set-CsOnlineVoicemailUserSettings -VoicemailEnabled $false

8. Call Recording

If you wish to set up call recording on your Teams Tenant and find out how to view/download recorded calls please refer to ‘Guide to Jola Call Recording platform, available here: https://support.jola.co.uk/portal/en/kb/articles/guide-to-jola-call-recording-platform-v5

 


    • 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 Call Recording platform

      1. Introduction Jola call recording solution provides recording capabilities with flexible and secure controls on calls made via our SIP Trunks and Direct Routing. Call recording can be activated using SIP Manager. It is administered within a ...