Skip to content

Instantly share code, notes, and snippets.

Last active June 12, 2022 13:11
What would you like to do?
#Import the Azure AD Internals module.
Import-Module AADInternals
#Users to process
$Users = import-csv c:\temp\users.csv
foreach($user in $users){
$password = ConvertTo-SecureString $user.password -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList ($($user.upn), $password)
#Get the Teams token for user curently beeing processed.
$token = Get-AADIntAccessTokenForTeams -Credentials $cred
#URL to buddylists.
#The url is difrent depending on theregion your tenant is hosted in. This URL is from Europe, therefore EMEA in the URL.
#Example from the US is amer-03. See blogpost above for detqils on fidning this url.
$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"
#Number to Add. MRI is the phonenumber of the contact, same as phone property. If contact to be added is a internal user, add the request like this:
#To find the org id, run this command and look for it in a users buddies list:
#(Invoke-RestMethod -Uri $URL -Method GET -Headers $header -ContentType "application/json").value
$payload1 = @'
#Add phonenumber 1 to Speed Dial list.
Invoke-RestMethod -Uri $URL -Body $payload1 -Method POST -Headers $header -ContentType "application/json"
$payload2 = @'
#Add phonenumber 2 to Speed Dial list.
Invoke-RestMethod -Uri $URL -Body $payload2 -Method POST -Headers $header -ContentType "application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment