September 29, 2020

Using Powershell to assign phone numbers to MS Teams users.

Install the Skype for Business Online, Windows Powershell module.

Connect to Skype Online.

Import-Module SkypeOnlineConnector
$cred = Get-Credential
$session = New-CsOnlineSession -Credential $cred -Verbose
Import-PSSession -Session $session

The Microsoft 365 Domestic Calling Plan & Microsoft 365 Phone System licenses are required for users that need to be able to make outbound calls or be assigned a telephone number.

To list the licensed users, run the following command:

Get-CsOnlineVoiceUser | select Name, Id

To get the location ID (required to configure the user), run the following command:

Get-CsOnlineLisLocation

To assign an available telephony number to a licensed user, run the following command:

Set-CsOnlineVoiceUser -Identity <UserAccount> -TelephoneNumber <PhoneNumber> -LocationID <locationID>