Bulk Assigning Phone Number to Microsoft Teams Users / Direct Routing

MacSilverman 21 Reputation points
2022-06-16T15:27:20.89+00:00

Hello All,

I'm trying to bulk assign phone numbers for our end users in teams. The portal itself is very limited. I found this article.

https://learn.microsoft.com/en-us/powershell/module/teams/set-csphonenumberassignment?view=teams-ps

I ran this command line to one of my test accounts. It worked perfectly.

$loc=Get-CsOnlineLisLocation -City Vancouver
Set-CsPhoneNumberAssignment -Identity user2@Company portal .com -PhoneNumber +12065551224 -PhoneNumberType CallingPlan -LocationId $loc.LocationId

The issue is that I need to setup over 500+ users in the next two months. The portal can only process one at a time.

I did find an exact question from this site from last year, but I believe Microsoft changed the commands. I tried running the commands they had answer on that question, but it didn't work.

This is the command from the other question.

"$teams = Import-Csv C:\Users\test\teamsuser.csv"

foreach ($team in $teams){
$number = "TEL:+" + $TEAM.phonenumber
Set-CSuser -Identity $team.IdentityName -OnpremLineURI $number -EnterpriseVoiceenabled $true -HostedVoiceMail $true }

Thank you,

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,131 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,876 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,382 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tiaan 736 Reputation points
    2022-06-16T21:25:59.077+00:00

    Hi @MacSilverman

    Some of the commands you have there have been deprecated. When assigning bulk user, I use the following in conjunction with a csv file:

    $teams = Import-Csv "C:\Users\Temp\FILENAME.csv"
    foreach ($team in $teams) {
    Set-CsPhoneNumberAssignment -identity $team.identityname -PhoneNumber $team.phonenumber -PhoneNumberType DirectRouting
    Grant-CsTenantDialPlan -PolicyName "YOURPOLICYNAME" -Identity $team.identityname
    Grant-CsTeamsCallingPolicy -PolicyName AllowCalling -Identity $team.identityname
    Grant-CsOnlineVoiceRoutingPolicy -PolicyName "YOURPOLICYNAME"-Identity $team.identityname
    }

    If you have the policies assigned allready you only need to run the Set command.

    The Csv format is as follows: identityname,phonenumber

    Hope this helps.

    Regards,
    Tiaan

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. MacSilverman 21 Reputation points
    2022-06-16T22:07:39.423+00:00

    Thank you so much. That worked.

    0 comments No comments