MS Teams Contact Provisioning…A Better Way

MS Teams Contact Provisioning

Have you ever thought that it might be great to use MS Teams Contact Provisioning in an automated way? It would help if you didn’t have to manually enter in all those pesky numbers. I don’t know about you, but I like to know who’s calling by name instead of trying to remember an multi-digit number on the display.

The problem is there is no official way (or centralized way) to administrate this through teams admin, PowerShell, or Graph API. Man, that is a lot of choices. why doesn’t MS just pull the trigger and give us a way already! I have shown how to administer Outlook contacts centrally so why not MS Teams Contacts! There is a behind the scenes way but it does take a little bit of forensic work!

I got a little help from this article, but I will also show you ways to do more than just add MS Teams contact records.

Use Teams Web Client In Dev Mode

First, log in to your Teams web client, and open dev mode (F12) of your browser. You are able to see what is happening in the background. You can see all actions as they happen in the web client if you look closely. These are the API calls.

MS Teams Contact Provisioning

What I did was manually Add, Change and Delete a contact and looked for the API calls. You will see some interesting things:


Here we can see the request URL, method, and body/payload. I have shown the URL method for an Add, Change and Delete. If you look closely at the request URL, it will show where your tenant is located. I am in North America so you will see AMER in the If you are in Europe it will be more than likely EMEA. We also see a token we can use to authenticate with. The issue though, this is only valid for this single user and expires in about an hour.

Is This Method Feasible?

This does not scale very well when doing a lot of provisioning and adding many contacts to the speed dial list. So how do we get the user’s token in a more automatic way? This where I was able to get some assistance from the article I cited above and use a PowerShell module developed by Dr. Nestori Syynimaa called AADInternals. You can install it by running “Install-Module AADInternals” in PowerShell. This module has a cmdlet called Get-AADIntAccessTokenForTeams, which contains a parameter called -Credentials. This parameter accepts a username/password.

I reiterate, this does not scale well. You can add the contacts to a new user when you know their password (initialing setting up their account). But after that, they are on their own dealing with moves adds and changes. I am sure you are good admin and when they get their initial password you make them change it. However, in small companies you should be able to do it for your users. Just have them come to your desk and when you run this script, have them put in their credentials. That is why I have shown you the API calls for that.

The PowerShell Script for MS Teams Contact Provisioning

Now it is just a matter of generating the script:

# X

#Import the Azure AD Internals module.

Import-Module AADInternals

#Get the Teams token for user curently beeing processed.

$token = Get-AADIntAccessTokenForTeams -Credentials $cred

#URL to buddylists.

$URL = ""

$header = @{Authorization = "Bearer $token"}

#Get id of the Speed Dial list.

$ListID = ((Invoke-RestMethod -Uri $URL  -Method GET -Headers $header -ContentType "application/json").value | Where-Object{$_.displayname -like "Favorites"}).id

#URL for the Speed Dial list.

$URL = "$ListID/managebuddies?migrationRequested=true&federatedContactsSupported=true"

#Now look add the above line buddylist is for ADD. Use updateBuddy for CHANGE and removeBuddy for DELETE

$payload1 = @'
{"add":[{"mri":"4:(123) 456-7890","displayName":"John Smith","phone":"(123) 456-7890","companyName":"Acme Corporation","jobTitle":"President"}]}

#and don't forget to change this line above for change and delete to the lines in the white screen caps above 

It Is Still A Lot of Manual Work for MS Teams Contact Provisioning But…

You see, constructing the Payload statement can be very time consuming, especially if you have a lot of contacts to add but it doesn’t have to be this way. If you use a VB.Net App I created, it will generate the statements you need quickly to a text file. All you have to do is copy and paste the generate payload statements into the script and viola! The app only does ADD and DELETE en masse. You have all the code you need to do MS Teams Contact Provisioning!

Quick IT TIps!

Don’t miss these tips!

We don’t spam! Read our privacy policy for more info.

Avatar photo

I am an IT professional with over twenty years experience in the field. I have supported thousands of users over the years. The organizations I have worked for range in size from one person to hundreds of people. I have performed support from Help Desk, Network / Cloud Administration, Network Support, Application Support, Implementation and Security.

Pin It on Pinterest