Yet another simple powershell script for Teams

Author by Brett Janzen

I have been working with sys admins on how we could simplify adding phone numbers to a Microsoft Teams User. When adding numbers to users when Direct Routing is used, it has to be done via powershell. I wanted to create a simple check to make sure they are adding a +1 for E.164.

In this snip it I prompt for the username and the phone number they would like to assign to the user. Simple logic is looking for +1 in the UserPhoneNumber var.

$UserID =  Read-host -prompt 'User Email Address'
 $UserPhoneNumber = Read-Host -prompt 'Phone number'
 if ($UserPhoneNumber -like '+1*') {
 write-host "True"
 Set-CsUser -Identity $UserID -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:$UserPhoneNumber -verbose 
 } else {
 Write-host "please enter +1 and the 10 Digit Number"
 }

Next phase I will work on reading from a file and running this as a schedule task. Creating an automatized process.