Write Microsoft Teams Number to OnPremise AD

Let’s perform Teams Magical Spell Today which has been requested by Customer’s Telecom Team.

Requirement is to Write the Microsoft Teams assigned number to Onpremise AD attribute i.e. Business Phone.

PowerShell Script shared in this post will fulfill the requirement.

Parameters Used:

##################################################

[Parameter(Mandatory = $true)]

[string]$domain,

[Parameter(Mandatory = $true)]

[string]$ADattribute,

[Parameter(Mandatory = $true)]

[ValidateSet(‘True’,’False’)]

[string]$reportonly,

[Parameter(Mandatory = $true)]

[int]$countofchanges

#################################################

$domain : Your tenant name for example techwizard.onmicrosoft.com àtechwizard is the value that needs to be entered here.

$ADattribute: Attribute in Active directory that you want Teams assigned number to be written for example: telephonenumber

$reportonly: True or False (True if you want that it should just report and False if you want it to write to active directory)

$countofchanges: This is threshold, it depends on environment (first time you can make it large enough to process everything and after that on subsequent run you can select the lower number)

 

Modules used:

Script will generate CSV report which will show the telephone numbers that are already present, that are updated and accounts that are not found in local AD (may be because these are cloud only)

It will also generate detail log inside the logs folder.

 

Download the script from Github or install it from Powershell gallery.

https://github.com/VikasSukhija/Downloads/blob/master/TeamsNumbers2ADAttribute.ps1

https://www.powershellgallery.com/packages/TeamsNumbers2ADAttribute

Install-Script -Name TeamsNumbers2ADAttribute

 

Here is the snippet to show how you can execute it. (it will ask for admin credentials so that it can connect to the relevant environments)


It will start fetching all the Microsoft teams assigned number and start comparing with existing values in AD attribute.

Write-Progress has been used so that we know the progress.


Check the CSV report inside reports folder after script completion, status column will show the action script has taken.

Match means: no action required.

Update Number means: Number written to AD

Not found means: User not found in AD.

 

Thanks for reading and downloading…

Tech Wizard
https://techwizard.cloud
https://syscloudpro.com/
PowerShell Cheat Book

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s