top of page
  • Writer's picturesamanthaeasterday

Creating E164 numbers and enabling PowerShell to enable Teams Voice

Updated: Mar 24, 2022


I need a clear and easy process to enable users for Teams Phone System, no matter how many users. I've done deployments with 10 users, sure I'll click my mouse 30 times. But anymore than 10, PowerShell is my best friend. Not only does it help from making human mistakes, its fun to use!...Once you have working scripts :).

When I receive data from a customer, 100% of the time, it is not in the format I need. So I've gotten pretty good at Excel (good is a very

strong word for my Excel skills). When I am given something like this:

I need to be able to format line items PowerShell needs.

For this script I need their SIP address and I need to put their DID in E164 format. The email address is usually their email address (verify this). So I put my focus towards the DID.

I often question the need of 4 digit dialing with Teams, but I get asked about all the time. Also, if you have an Auto Attendant set up for Extension Dialing, you will need to include ;ext=xxxx so Teams knows what extension you are referring to. It is supported to have a different extension than your last 4 digits, and this is how you accomplish that as well.

First you need to copy the last 4 digits of the DID (assuming they match with your internal dialing). We will use empty cell C8 and will type:

=Right (C7,4)

The output will be:


Now you need to create the full E164 number. In C8, type:


The output will be:


Then clean up the spreadsheet with just the user's email address and TeamsDID and save it as a .csv file.

Now open PowerShell ISE in admin mode. I'm going to assume you already have the Teams module installed. But you will also need the MSOnline module (for assigning licenses).

Install-Module MSOnline


Then you'll also want to connect to Teams module.



Enter your M365 admin creds

Once loaded, you are ready to enable your users for Teams Phone System. To enable the dialpad in Teams, the user needs 3 things.

Phone System License (MCOEV)

Enterprise Voice Enabled

Assigned Voice Routing Policy

This script will cover all 3. Copy and paste into PowerShell ISE

#Script to Teams Voice enable users



$Users = Import-Csv -Path C:\temp\TeamsUsers2.csv

$sip = $user.user

$lineuri = $user.TeamsDID

ForEach($user in $Users) {

Set-MsolUserLicense -UserPrincipalName $sip -AddLicenses "MCOEV" -ErrorAction SilentlyContinue

Set-CsUser -Identity $sip -EnterpriseVoiceEnabled $true -LineURI $lineuri

Grant-csonlinevoicemailpolicy -Identity $sip -PolicyName Default

Grant-CsOnlineVoiceRoutingPolicy -Identity $sip -PolicyName "PolicyName" -verbose


A few key things to note:

Update based on headers in your .csv file

AddLicense is the Phone System license (but that line can be used for other licenses as well)

Update -PolicyName to your Voice Routing Policy in Teams.

It could take up to 24hrs for the dial pad to show up in the Teams client.

Hope this helps!

74 views0 comments


bottom of page