How can Teams phone numbers be synced automatically to on-premises Active Directory?
Asked by
MellowBirch42
Our carrier assigns mobile and landline numbers to users in Teams, while user accounts are managed in on-premises Active Directory and synchronized to Entra ID with Entra Connect. The phone fields in AD are currently updated manuallyโor not at allโso Teams, Entra ID, and the Outlook address book often show different numbers. Some users have a working Teams number but no directory entry, while others still display an outdated number. Has anyone automated this synchronization? I'm especially interested in whether you used a PowerShell script, an automation runbook, or a third-party tool; which system you chose as the source of truth; which AD attributes you populated, such as telephoneNumber, mobile, or ipPhone; how you handled unpublished or exceptional numbers; and what permissions were required in Teams, Entra ID, and Active Directory.
Answers
We query our phone providerโs API, write the results into the standard telephoneNumber attribute in on-premises AD, and let Entra Connect synchronize the changes. The script runs on an internal server several times a day. This works well when the carrier or phone platform is the authoritative source rather than trying to maintain a two-way sync.
Reply to this answer
Choose one system of record before automating anything. If AD drives the address book, populate telephoneNumberโand mobile or ipPhone only when you have a clearly defined purposeโand allow the normal Entra synchronization to carry the data onward. Exclude call queues, auto attendants, unassigned numbers, users who should not be listed, and people with pending offboarding. A two-way sync can overwrite intentional exceptions or create a loop when someone changes a number manually.
Reply to this answer
A scheduled PowerShell job can handle this. Use the Teams or phone-system API to retrieve assigned numbers, match them to the corresponding users, and update the selected AD attributes. Running it on an internal Windows server as a scheduled task is straightforward, though an Azure Automation runbook is another option if it can securely reach your directory.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions