How to Fix “Set-Csuser : This cmdlet has been deprecated” in Teams PowerShell

This post is to fix the “Set-Csuser : This cmdlet has been deprecated. Use the new Set-CsPhoneNumberAssignment and Remove-CsPhoneNumberAssignment cmdlets instead” error in Teams PowerShell.

Environment

*Microsoft Teams configured with Direct Routing for PSTN calling

*All users Were migrated from On-Prem Skype for Business

*All AD users are created locally in Domain Controller first, then synced via Azure AD Connect

*There is NO Skype for Business anymore, all users are on “UpgradeToTeams” / “Teams Only” mode

* Administrator used to run the below command to enable Teams PSTN calling ability and now gives us an error

Set-Csuser -Identity "[email protected]" -EnterpriseVoiceEnabled $true -HostedVoiceMail $True

Fix

Because the error is very straightforward, the fix is simple here.

====Firstly, make sure there are NO on-prem SFB/Teams AD attributes attached to this user; we only care about the “MSRTC…” section of the attributes

====Remove the attributes and do a “Delta” sync on your Azure AD Connect Server

Start-ADSyncSyncCycle -PolicyType Delta

====Run the new Set-CsPhoneNumberAssignment command to enable the “EnterpriseVoiceEnabled” option

Set-CsPhoneNumberAssignment -Identity "[email protected]" -PhoneNumber "+61xxxxxxxxx;ext=xxxx" -PhoneNumberType DirectRouting

====Now you can run a “Get-CsOnlineUser” to check whether it is working

Useful link

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

Note

Overall commands to enable a user in a “Direct Routing” configured Teams environment

Connect-MicrosoftTeams

Grant-CsOnlineVoiceRoutingPolicy -Identity "[email protected]" -PolicyName "Your Voice Routing Policy"

Grant-CSTeamsUpgradePolicy -Identity [email protected] -PolicyName UpgradeToTeams

Set-CsPhoneNumberAssignment -Identity "[email protected]" -PhoneNumber "+61xxxxxxxxx;ext=xxxx" -PhoneNumberType DirectRouting

Grant-CsTenantDialPlan -Identity "[email protected]" -PolicyName "Your Dial Plan"

Leave a Comment

Your email address will not be published. Required fields are marked *