Microsoft Teams PowerShell Phone Number Assigning Cmdlet Change

Microsoft has sent out an announcement on PowerShell changes for setting and removing phone numbers in Microsoft Teams:

Changes coming to phone number assignment using Teams PowerShell Module cmdlets
MC316139 · Published 19 Jan 2022

In summary, these commands are being deprecated “The retirement is planned to begin in early April and be complete by mid-April.” :


and Set-CSUser can’t be used to allocate phone numbers either. I’d been allocating numbers with the Set-CsOnlineVoiceUser command. The replacement for this is:

Set-CsPhoneNumberAssignment and Remove-CsPhoneNumberAssignment

They run under the MicrosoftTeams module for PowerShell, but you also need to make sure you have the latest version. If you don’t have a version that supports this new command, you’ll get the error:

Set-CsPhoneNumberAssignment : The term 'Set-CsPhoneNumberAssignment' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1

To update, run the command:

Update-module MicrosoftTeams 

Then try the above cmdlet again. If you’re feeling really brave, you can update all your modules with:

Update-module *

Disconnect or restart PowerShell or you’ll get problems running the new cmdlet if you had it connected while updating.

The new cmdlet Set-CsPhoneNumberAssignment doesn’t work exactly the same way as the old cmdlets. Read the documentation for more details

Set-CsPhoneNumberAssignment -Identity [email protected] -PhoneNumber +61987654321 -PhoneNumberType CallingPlan

The options for -PhoneNumberType (required) are DirectRouting, CallingPlan and OperatorConnect.

I’d suggest testing and migrating soon, before you miss the April deadline of the command being dropped.

17 thoughts on “Microsoft Teams PowerShell Phone Number Assigning Cmdlet Change

  1. Same issue with Telstra in Australia for me Adam – 24/01/2022 – I thought I was going nuts with licences until I read the first part of your post.

    1. Hi Ben & Adam, First of all thank you for this post, it was very helpful. I am also located in Australia and use Telstra / Teams Phone in my organisation. Have either of you experienced issues assigning a phone number to a new user in both the Teams Admin portal & PowerShell over the last couple of weeks? I cannot assign a number to one specific new user (other new users created since have no problem) and the date I first noticed this issue seems to coincide with this post/Cmdlet Change (late Jan 2022).

      In Teams Admin portal I get the error “We can’t save changes for number +61 X XXXX XXXX right now. Try again later.” when assigning a number to this user.

      And in PowerShell I get the following result using the updated Cmdlet above:

      Code Message
      —- ——-
      BadRequest The user ” is not found

      I have tried multiple unassigned user numbers we have, even ones from completely different ranges. I have confirmed licencing (including removing and re-adding the licence), I’ve confirmed the user’s TenantID and ObjectID is matching. I’ve compared the output of Get-CsOnlineVoiceUser against another working user and all the details match (including SIPDomain, DataCenter, TenantId, LicenceState, PSTNConnectivity = True, UsageLocation and EnterpriseVoiceEnabled = True). Confirmed a valid emergency location is set (the same as our other 180 users). Nothing seems to be out of the ordinary and it’s driving me nuts.

      I have an open case with MS Support but nothing has been resolved and they aren’t giving me much info and is exacerbated by the time zone difference (going on a week now). So I am desperately trying to find info anywhere (which is what led me to this post).

      I understand this is not a support forum, so apologies if this is inappropriate. Please delete, or let me know to delete it if so. Any ideas would be greatly appreciated. We use a Hybrid environment if that helps.

      1. I’ve seen the “We can’t save changes for number +61 X XXXX XXXX right now. Try again later.” problem which was a problem in the portal itself, but PowerShell command did work. Does the get-csuser and get-teamuser commands work? Can also come along to the WinAdmins discord for a better way of troubleshooting this vs comments here (although if we get a fix should post it here!)

  2. Sorry all, so is Set-CSUser working for you? The updated commands do work but old arent at all now and MS support are confused too.

    1. When the new command wasn’t working, I failed back to the old commands successfully. They should be working up until April. What error are you getting when trying?

      1. Its just not assigning the number. I have changed our setup scripts to be as below for a direct routed user. There are some slight adjustments needs for an online user, as you now have to set the emergency location at the same time. For a direct routing user you cant run the -EnterpriseVoice switch and the -PhoneNumber switch at the same time either. I am still shouting at Microsoft on a dialy basis until I hear back from the product team:

        Get-PSSession | Remove-PSSession
        Import-Module Microsoftteams
        $CSV = Import-CSV “c:\SkypeScripts\Template.csv”

        Write-Host “Enabline users in Teams”

        #Enable for VoiceEnterprise

        ForEach ($u in $csv) {

        Write-Host “Set-CsPhoneNumberAssignment -Identity $($u.SipAddress) -EnterpriseVoiceEnabled `$true ” -ForegroundColor Cyan

        Set-CsPhoneNumberAssignment -Identity $u.SipAddress -EnterpriseVoiceEnabled $true


        #Set Phone Number

        ForEach ($u in $csv) {

        Write-Host “Set-CsPhoneNumberAssignment -Identity $($u.SipAddress) -PhoneNumber $($u.LineURI) -PhoneNumberType DirectRouting” -ForegroundColor Cyan

        Set-CsPhoneNumberAssignment -Identity $u.SipAddress -PhoneNumber $u.LineURI -PhoneNumberType DirectRouting


        #Enable VoiceMail

        ForEach ($u in $csv) {

        Write-Host “Set-CsOnlineVoicemailUserSettings -Identity $($u.SipAddress) -VoicemailEnabled `$true” -ForegroundColor Cyan

        Set-CsOnlineVoicemailUserSettings -Identity $u.SipAddress -VoicemailEnabled $true


        Write-Host “Sleeping 10 secs then granting voice policy to users”
        Start-Sleep 10

        ForEach ($u in $csv) {

        Write-Host “Grant-CsOnlineVoiceRoutingPolicy -Identity $($u.SipAddress) -PolicyName $($u.VoicePolicy)” -ForegroundColor Cyan

        Grant-CsOnlineVoiceRoutingPolicy -Identity $u.SipAddress -PolicyName $u.VoicePolicy


        Write-Host “Sleeping 10 secs then granting dial plan to users”
        Start-Sleep 10

        ForEach ($u in $csv) {

        Write-Host “Grant-CsTenantDialPlan -Identity $($u.SipAddress) -PolicyName $($u.TenantDialPlan)” -ForegroundColor Cyan

        Grant-CsTenantDialPlan -Identity $u.SipAddress -PolicyName $u.TenantDialPlan


        Write-Host “Switching Users to Teams Only”

        ForEach ($u in $csv) {

        Write-Host ” Grant-CsTeamsUpgradePolicy -Identity $($u.SipAddress) -PolicyName UpgradeToTeams” -ForegroundColor Cyan

        Grant-CsTeamsUpgradePolicy -Identity $u.SipAddress -PolicyName UpgradeToTeams


    2. Hi Jon, Can you please share an example template file together with the updates PowerShell script pls?
      Thanks for sharing this very useful article

      1. The “template file” is just a CSV with the headings below:

        I dont think the script has changed to the one above.

  3. Morning from the UK.

    Could you share your PS? We have online users too as well as direct routed and I had to change our PS to use the new cmdlet. I have a catchup with our Microsoft engineer too this morning.

    Just checking though as I noticed another change in the portal. Have you assigned a calling plan before trying to allocate a number or is this a direct routing user?

    1. Hi Jon,
      I’m doing these three commands for a new user:

      Grant-CsTenantDialPlan -Identity %username% -PolicyName %physicalDeliveryOfficeName%
      Set-CsOnlineVoiceUser -Identity %username% -TelephoneNumber %Phone%
      Set-CsPhoneNumberAssignment -Identity %username% -Phonenumber %Phone% -Phonenumbertype CallingPlan

  4. So final response for Microsoft is that the product team upgraded some tenancies (by mistake) ahead of the April cut over of the SET-CSUSER command. They are sorry – that is all.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.