AdamFowlerIT.com
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.” :
Set-CsOnlineVoiceUser Set-CsOnlineApplicationInstance Set-CsOnlineVoiceApplicationInstance
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:
To update, run the command:
Then try the above cmdlet again. If you’re feeling really brave, you can update all your modules with:
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
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.
Share this:
17 thoughts on “ microsoft teams powershell phone number assigning cmdlet change ”.
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.
Hi Ben, I’ve had Microsoft confirm it’s a bug, hopefully fixed soon :)
Yes it is fixed now. I have try it today and able to assign the phone number.
Yes it’s now fixed :)
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.
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!) https://discord.com/invite/winadmins
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.
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?
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 Connect-MicrosoftTeams 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
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
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
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
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”
Write-Host ” Grant-CsTeamsUpgradePolicy -Identity $($u.SipAddress) -PolicyName UpgradeToTeams” -ForegroundColor Cyan
Grant-CsTeamsUpgradePolicy -Identity $u.SipAddress -PolicyName UpgradeToTeams
Hi Jon, Can you please share an example template file together with the updates PowerShell script pls? Thanks for sharing this very useful article
The “template file” is just a CSV with the headings below: UserPrincipalName,SipAddress,LineURI,EnterpriseVoiceEnabled,VoicePolicy,TenantDialPlan
I dont think the script has changed to the one above.
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?
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
See above Adam F
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.
Haha oops, did they fix it?
They cant, so we have the all of the new features too (such as Cortana in the meeting room devices).
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed .
Navigation Menu
Search code, repositories, users, issues, pull requests..., provide feedback.
We read every piece of feedback, and take your input very seriously.
Saved searches
Use saved searches to filter your results more quickly.
To see all available qualifiers, see our documentation .
- Notifications You must be signed in to change notification settings
Set-CsPhoneNumberAssignment.md
Latest commit, file metadata and controls, set-csphonenumberassignment.
This cmdlet will assign a phone number to a user or a resource account (online application instance).
LocationUpdate (Default)
Networksiteupdate, reversenumberlookup, description.
This cmdlet assigns a phone number to a user or resource account. When you assign a phone number the EnterpriseVoiceEnabled flag is automatically set to True.
You can also assign a location to a phone number.
To remove a phone number from a user or resource account, use the Remove-CsPhoneNumberAssignment cmdlet.
This example assigns the Microsoft Calling Plan phone number +1 (206) 555-1234 to the user [email protected] .
This example finds the emergency location defined for the corporate location Vancouver and assigns the Microsoft Calling Plan phone number +1 (206) 555-1224 and location to the user [email protected] .
This example sets the EnterpriseVoiceEnabled flag on the user [email protected] .
This example removes the emergency location from the phone number for user [email protected] .
This example assigns the Direct Routing phone number +1 (425) 555-1225 to the resource account [email protected] .
This example assigns the Direct Routing phone number +1 (425) 555-1000;ext=1234 to the user [email protected] .
This example shows how to use Try/Catch and ErrorAction to perform error checking on the assignment cmdlet failing.
This example shows how to change the location for unassigned Calling Plan subscriber phone numbers by looping through all the phone numbers, assigning each phone number temporarily with the new location to a user, and then unassigning the phone number again from the user.
This example shows how to set the location on a phone number.
This Example shows how to update the LocationID from an old location to a new location for a set of phone numbers.
This example shows how to turn off reverse number lookup (RNL) on a phone number. When RNL is set to 'SkipInternalVoip', an internal call to this phone number will not attempt to pass through internal VoIP via reverse number lookup in Microsoft Teams. Instead the call will be established through external PSTN connectivity directly. This example is only applicable for Direct Routing phone numbers.
-AssignmentCategory
This parameter is reserved for internal Microsoft use.
-EnterpriseVoiceEnabled
Flag indicating if the user or resource account should be EnterpriseVoiceEnabled.
This parameter is mutual exclusive with PhoneNumber.
The Identity of the specific user or resource account. Can be specified using the value in the ObjectId, the SipProxyAddress, or the UserPrincipalName attribute of the user or resource account.
-LocationId
The LocationId of the location to assign to the specific user. You can get it using Get-CsOnlineLisLocation. You can set the location on both assigned and unassigned phone numbers.
Removal of location from a phone number is supported for Direct Routing numbers and Operator Connect numbers that are not managed by the Service Desk. If you want to remove the location, use the string value null for LocationId.
-NetworkSiteId
-phonenumber.
The phone number to assign to the user or resource account. Supports E.164 format like +12065551234 and non-E.164 format like 12065551234. The phone number can't have "tel:" prefixed.
We support Direct Routing numbers with extensions using the formats +1206555000;ext=1234 or 1206555000;ext=1234 assigned to a user or resource account.
Setting a phone number will automatically set EnterpriseVoiceEnabled to True.
-PhoneNumberType
The type of phone number to assign to the user or resource account. The supported values are DirectRouting, CallingPlan, and OperatorConnect. When you acquire a phone number you will typically know which type it is.
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters .
System.Object
The cmdlet is available in Teams PowerShell module 3.0.0 or later. The parameter set LocationUpdate was introduced in Teams PowerShell module 5.3.1-preview. The parameter NetworkSiteId was introduced in Teams PowerShell module 5.5.0. The parameter set NetworkSiteUpdate was introduced in Teams PowerShell module 5.5.1-preview.
The cmdlet is only available in commercial and GCC cloud instances.
If a user or resource account has a phone number set in Active Directory on-premises and synched into Microsoft 365, you can't use Set-CsPhoneNumberAssignment to set the phone number. You will have to clear the phone number from the on-premises Active Directory and let that change sync into Microsoft 365 first.
The previous command for assigning phone numbers to users Set-CsUser had the parameter HostedVoiceMail. Setting HostedVoiceMail for Microsoft Teams users is no longer necessary and that is why the parameter is not available on Set-CsPhoneNumberAssignment.
RELATED LINKS
Remove-CsPhoneNumberAssignment
Get-CsPhoneNumberAssignment
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Get-Cs Phone Number Assignment
This cmdlet displays information about one or more phone numbers.
Description
This cmdlet displays information about one or more phone numbers. You can filter the phone numbers to return by using different parameters.
Returned results are sorted by TelephoneNumber in ascending order.
If you are using both -Skip X and -Top Y for filtering, the returned results will first be skipped by X, and then the top Y results will be returned.
By default, this cmdlet returns a maximum of 500 results.
This example displays information about the Microsoft Calling Plan subscriber phone number +1 (402) 555-1234. You can see that it is assigned to a user.
This example displays information about the Direct Routing phone number +1 (206) 555-1000;ext=524. You can see that it is assigned to a user.
This example returns all phone numbers that have both the capability VoiceApplicationAssignment and the capability ConferenceAssignment assigned, but phone numbers that have only one of these capabilities assigned won't be returned.
This example returns information about the phone number assigned to [email protected].
This example returns information about the phone number assigned to resource account [email protected].
This example returns information about all activated phone numbers with the capability VoiceApplicationAssignment that are not assigned.
This example returns information about all phone numbers that contain the digits 524, including the phone number with extension 524 used in example 2.
This example returns the number of Calling Plan subscriber phone numbers that are either assigned or not assigned to users.
This example returns the number of Calling Plan or Operator Connect service phone numbers that can be assigned to voice applications and conference bridges.
This example returns all phone numbers.
This example returns all phone numbers assigned as emergency numbers in the Teams shared calling routing policy instance SC1.
This example displays when SkipInternalVoip option is turned on for a number.
-ActivationState
Filters the returned results based on the number type. Supported values are Activated, AssignmentPending, AssignmentFailed, UpdatePending, and UpdateFailed.
-AssignedPstnTargetId
Filters the returned results based on the user or resource account ID the phone number is assigned to. Supported values are UserPrincipalName, SIP address, ObjectId, and the Teams shared calling routing policy instance name.
-AssignmentCategory
This parameter is reserved for internal Microsoft use.
-CapabilitiesContain
Filters the returned results based on the capabilities assigned to the phone number. You can specify one or more capabilities delimited by a comma. Supported capabilities are ConferenceAssignment, VoiceApplicationAssignment, UserAssignment, and TeamsPhoneMobile.
If you specify only one capability, you will get all phone numbers returned that have that capability assigned. If you specify a comma separated list for instance like ConferenceAssignment, VoiceApplicationAssignment you will get all phone numbers that have both capabilities assigned, but you won't get phone numbers that have only VoiceApplicationAssignment or ConferenceAssignment assigned as capability.
-CivicAddressId
Filters the returned results based on the CivicAddressId assigned to the phone number. You can get the CivicAddressId by using Get-CsOnlineLisCivicAddress .
-IsoCountryCode
Filters the returned results based on the ISO 3166-1 Alpha-2 country code assigned to the phone number.
-LocationId
Filters the returned results based on the LocationId assigned to the phone number. You can get the LocationId by using Get-CsOnlineLisLocation .
-NetworkSiteId
-numbertype.
Filters the returned results based on the number type. Supported values are DirectRouting, CallingPlan, and OperatorConnect.
-PstnAssignmentStatus
Filters the returned results based on the assignment status. Support values are Unassigned, UserAssigned, ConferenceAssigned, VoiceApplicationAssigned, ThirdPartyAppAssigned, and PolicyAssigned.
Skips the first X returned results and the default value is 0.
-TelephoneNumber
Filters the returned results to a specific phone number. It is optional to specify a prefixed "+". The phone number can't have "tel:" prefixed. We support Direct Routing numbers with extensions using the formats +1206555000;ext=1234 or 1206555000;ext=1234.
-TelephoneNumberContain
Filters the returned results based on substring match for the specified string on TelephoneNumber. To search for a number with an extension, you need to specify the digits of the extension. For supported formats see TelephoneNumber.
-TelephoneNumberGreaterThan
Filters the returned results based on greater than match for the specified string on TelephoneNumber. Can be used together with TelephoneNumberLessThan to specify a range of phone numbers to return results for. For supported formats see TelephoneNumber.
-TelephoneNumberLessThan
Filters the returned results based on less than match for the specified string on TelephoneNumber. Can be used together with TelephoneNumberGreaterThan to specify a range of phone numbers to return results for. For supported formats see TelephoneNumber.
-TelephoneNumberStartsWith
Filters the returned results based on starts with string match for the specified string on TelephoneNumber. For supported formats see TelephoneNumber.
Returns the first X returned results and the default value is 500.
ActivationState
The activation state of the telephone number.
AssignedPstnTargetId
The ID of the object the phone number is assigned to, either the ObjectId of a user or resource account or the policy instance ID of a Teams shared calling routing policy instance.
AssignmentCategory
The list of capabilities assigned to the phone number.
The city where the phone number is located.
CivicAddressId
The ID of the CivicAddress assigned to the phone number.
IsoCountryCode
The ISO country code assigned to the phone number.
IsoSubDivision
The subdivision within the country/region assigned to the phone number, for example, the state for US phone numbers.
The ID of the Location assigned to the phone number.
LocationUpdateSupported
Boolean stating if updating of the location assigned to the phone number is allowed.
NetworkSiteId
NumberSource
The source of the phone number. Online for phone numbers assigned in Microsoft 365 and OnPremises for phone numbers assigned in AD on-premises and synchronized into Microsoft 365.
The type of the phone number.
The ID of the operator.
PortInOrderStatus
The status of any port in order covering the phone number.
PstnAssignmentStatus
The assignment status of the phone number.
PstnPartnerId
The ID of the PSTN partner providing the phone number.
PstnPartnerName
The name of the PSTN partner.
TelephoneNumber
The phone number. The number is always displayed with prefixed "+", even if it was not assigned using prefixed "+".
The object returned is of type SkypeTelephoneNumberMgmtCmdletAcquiredTelephoneNumber.
ReverseNumberLookup
Status of Reverse Number Lookup (RNL). When it is set to SkipInternalVoip, the calls are handled through external PSTN connection instead of internal VoIP lookup.
The cmdlet is available in Teams PowerShell module 4.0.0 or later. The parameter AssignmentCategory was introduced in Teams PowerShell module 5.3.1-preview. The parameter NetworkSiteId was introduced in Teams PowerShell module 5.5.0. The output parameter NumberSource was introduced in Teams PowerShell module 5.7.0.
The cmdlet is only available in commercial and GCC cloud instances.
Related Links
- Remove-CsPhoneNumberAssignment
- Set-CsPhoneNumberAssignment
Was this page helpful?
IMAGES
VIDEO
COMMENTS
Nov 23, 2024 · This example shows how to change the location for unassigned Calling Plan subscriber phone numbers by looping through all the phone numbers, assigning each phone number temporarily with the new location to a user, and then unassigning the phone number again from the user.
Jan 21, 2022 · 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
When you set up Calling Plans, Operator Connect, or Teams Phone Mobile, you assign phone numbers to your users. In Microsoft Teams, the phone number that you assign is listed when a user clicks Calls .
Jan 24, 2022 · I'm facing an issue where I can't assign a Teams phone number (Canadian number issued by Microsoft) to a newly provisioned user via UI or PowerShell. The user was provisioned couple of days ago and the licenses/user location was perfectly set (as we normally do for every other request).
Jun 16, 2022 · 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
Oct 2, 2023 · Select “Plan and Implement your Teams Phone Deployment” and follow the steps. You’ll see a new user interface that simplifies assigning and setting up user phone numbers. You can view all the available phone numbers in your organization and filter them by phone number, service provider, or location.
PowerShell Reference for Office Products - Short URL: aka.ms/office-powershell - office-docs-powershell/teams/teams-ps/teams/Set-CsPhoneNumberAssignment.md at main · MicrosoftDocs/office-docs-powershell
NOTE: The phone number should be in E164 format. For external calls to work, the numbers you assign to a user should match the range of numbers assigned to you via Real World Technology Solutions (or an external calling provider).
Aug 15, 2022 · Hi everyone, I need assistance with Teams Voice Powershell. I need to bulk enable users for Direct Routing. I was using the below to enable and assign phone numbers individually/per user. Please assist with editing this so that I may be able to read user information and user phone number from a CSV file.
This example returns the number of Calling Plan or Operator Connect service phone numbers that can be assigned to voice applications and conference bridges. Example 10 Get-CsPhoneNumberAssignment -Top ([int]::MaxValue)