Forked from AlexanderHolmeset/TeamsSpeedDial.ps1
Last active
November 12, 2023 18:37
-
-
Save ColWhackaMole/b4f9130f49494eccfa1b5f3f8a398ba9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 the USA, therefore /part/amer-03/ in the URL. | |
$URL = "https://teams.microsoft.com/api/mt/part/amer-03/beta/contacts/buddylist/" | |
$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 = "https://teams.microsoft.com/api/mt/part/amer-03/beta/contacts/buddylist/$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: | |
#{"add":[{"mri":"8:orgid:18c4a91b-4fa9-4fbd-ab1c-b39465d81baf","displayName":"Admin","isFederated":false,"email":"[email protected]"}]} | |
#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":[{"mri":"4:123456789","displayName":"Helpdesk","phone":"123456789","companyName":"Contoso","jobTitle":""}]} | |
'@ | |
#Add phonenumber 1 to Speed Dial list. | |
Invoke-RestMethod -Uri $URL -Body $payload1 -Method POST -Headers $header -ContentType "application/json" | |
$payload2 = @' | |
{"add":[{"mri":"4:987654321","displayName":"Reception","phone":"987654321","companyName":"Contoso","jobTitle":""}]} | |
'@ | |
#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
Edited script from https://alexholmeset.blog/2021/12/13/microsoft-teams-speed-dial-contacts-provisioning/ to support USA tenants