VoIP:Teams:Microsoft Management: Difference between revisions

From VTX Public Wiki

(Remove -Username)
(Add screenshot)
 
(14 intermediate revisions by 3 users not shown)
Line 13: Line 13:




{{Notice|1=None of your user will use the <servicenumber>.teams.ipvoip.ch, but as stated in the Requirements above, we need to create a temporarily user in this domain with the Teams + Phone System licenses in order to be able to create the CsOnlineVoiceRoute towards VTX SBC}}
{{Warning|1=None of your user will use the <servicenumber>.teams.ipvoip.ch, but as stated in the Requirements above, we need to create a temporarily user in this domain with the Teams + Phone System licenses in order to be able to create the CsOnlineVoiceRoute towards VTX SBC}}




* '''Problematic''': We wish to create a enableteams@<servicenumber>.teams.ipvoip.ch to enable Teams connection towards VTX VoIP platform
* '''Problematic''': We wish to create a enableteams@'''<servicenumber>.teams.ipvoip.ch''' to enable Teams connection towards VTX VoIP platform
* '''Solution''': Please follow the procedure below
* '''Solution''': Please follow the procedure below
# Connect to https://admin.microsoft.com/Adminportal/Home#/users
# Connect to https://admin.microsoft.com/Adminportal/Home#/users
# Create a new user enableteams@<servicenumber>.teams.ipvoip.ch ( First Name: "Temp User" / Last Name : "VTX Teams" / Login : enableteams@<servicenumber>.teams.ipvoip.ch / No Admin Right / "Teams" and "Phone System" licenses / No need to remember its password, we won't connect with it).
# Create a new user enableteams@'''<servicenumber>.teams.ipvoip.ch''' ( First Name: "Temp User" / Last Name : "VTX Teams" / Login : enableteams@<servicenumber>.teams.ipvoip.ch / No Admin Right / "Teams" and "Phone System" licenses / No need to remember its password, we won't connect with it).
# Wait a few seconds/minutes/hours for Teams to be enabled on this user https://admin.microsoft.com/AdminPortal/Home#/teamsprovisioning
# Wait a few seconds/minutes/hours for Teams to be enabled on this user https://admin.microsoft.com/AdminPortal/Home#/teamsprovisioning
# Now even after user is created you night need to wait minutes/hours before being able to create Voice Routing ( especially the New-CsOnlineVoiceRoute ), so if you can please wait 4hours, if not, try to create the routing, if you get error, try again
# Now even after user is created you night need to wait minutes/hours before being able to create Voice Routing ( especially the New-CsOnlineVoiceRoute ), so if you can please wait 4hours, if not, try to create the routing, if you get error, try again
# Once everything is working ( routing + user mapping + incoming and outgoing calls ), you can delete this user to free up the licenses
# Once everything is working ( routing + user mapping + incoming and outgoing calls ), you can delete this user to free up the licenses



== Voice Routing : Create Voice Routing to allow your users to use VTX Trunk ==
== Voice Routing : Create Voice Routing to allow your users to use VTX Trunk ==
Line 64: Line 63:
# Open a powershell prompt on your PC
# Open a powershell prompt on your PC
# Copy paste command below one by one changing the values in bold with your own
# Copy paste command below one by one changing the values in bold with your own
<syntaxhighlight lang="powershell">
# Set Variables
$TeamsDomain = "123456.teams.ipvoip.ch"
# Connect to Microsoft Teams management and create all Voice Routing
Connect-MicrosoftTeams
Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="CsOnlinePstnUsage-$TeamsDomain"}
New-CsOnlineVoiceRoute -Identity "CsOnlineVoiceRoute-$TeamsDomain" -Priority 0 -NumberPattern '.*' -OnlinePstnGatewayList "$TeamsDomain" -OnlinePstnUsages "CsOnlinePstnUsage-$TeamsDomain"
New-CsOnlineVoiceRoutingPolicy -Identity "CsOnlineVoiceRoutingPolicy-$TeamsDomain" -OnlinePstnUsages "CsOnlinePstnUsage-$TeamsDomain"
Set-CsCallingLineIdentity -Identity Global -EnableUserOverride $True


# Verify all setup ( You can compare it with the Debug Section in the wiki )
# Set Variables
Get-CsOnlinePstnUsage
$MSTeamsDomain = '''"123456.teams.ipvoip.ch"'''
Get-CsOnlineVoiceRoute
# Connect to Microsoft Teams management and create all Voice Routing
Get-CsOnlineVoiceRoutingPolicy
$Session = New-CsOnlineSession
Get-CsCallingLineIdentity
Import-PSSession $Session -AllowClobber

Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="CsOnlinePstnUsage-$MSTeamsDomain"}

New-CsOnlineVoiceRoute -Identity "CsOnlineVoiceRoute-$MSTeamsDomain" -Priority 0 -NumberPattern '.*' -OnlinePstnGatewayList "$MSTeamsDomain" -OnlinePstnUsages "CsOnlinePstnUsage-$MSTeamsDomain"
# Create rule for emergency numbers (10-19, 100-199)
New-CsOnlineVoiceRoutingPolicy -Identity "CsOnlineVoiceRoutingPolicy-$MSTeamsDomain" -OnlinePstnUsages "CsOnlinePstnUsage-$MSTeamsDomain"
Set-CsCallingLineIdentity -Identity Global -EnableUserOverride $True
$emergencyRule = New-CsVoiceNormalizationRule -Identity "Global/Emergency Numbers" `
-Pattern '^(1[0-9]|1[0-9]{2})$' `
-Translation '$1' `
# Verify all setup ( You can compare it with the Debug Section in the wiki )
-Description "Emergency numbers" `
Get-CsOnlinePstnUsage
-InMemory
Get-CsOnlineVoiceRoute
# Create rule for short numbers (3xxx, 1xxx, 116xxx, 118xxx)
Get-CsOnlineVoiceRoutingPolicy
$shortRule = New-CsVoiceNormalizationRule -Identity "Global/Short Numbers" `
Get-CsCallingLineIdentity
-Pattern '^(3[0-9]{3}|1[0-9]{3}|11[68][0-9]{3})$' `
-Translation '$1' `
# Logout
-Description "Short numbers" `
Get-PSSession | Remove-PSSession
-InMemory
# Add rules to Global Dial Plan
Set-CsTenantDialPlan -Identity "Global" -NormalizationRules @{Add=$emergencyRule,$shortRule}
# Verify rules have been created
Get-CsTenantDialPlan -Identity "Global" | Select-Object Identity, NormalizationRules | Format-List

# Logout
Disconnect-MicrosoftTeams

</syntaxhighlight>


== Dial Plan for Emergency Numbers + Short Numbers + Special Setup ==
* '''History''':
** '''2026-01-21''': The addition and deletion of Emergency and Short number is directly included in version 4.7+ of the create routing and delete routing script
* '''Information''': By default if you try to dial a number, Teams Client will always try to normalize it in +e164 mode adding your country prefix like +41 or +33 to your number
* '''Problem''': If you call an emergency number like 112 or a Short number like 10XX or 3XXX or 116xxx or ..., it will add an invalid country prefix
* '''Problematic''': Add Dial Plan entries not to alter number dialed
* '''Symptoms''': Within the Teams Client, you will directly see if the number you are typing is being transformed with a county prefix or not. If it is transformed, you are missing the following rules
* '''Dialplan Documentation''': https://docs.microsoft.com/en-US/microsoftteams/create-and-manage-dial-plans
* '''Dialplan Web Admin Teams Management URL''': https://admin.teams.microsoft.com/one-policy/settings/dialplan
* '''Solution''': Use one of the solution

# Run again the create routing script on last version (4.7+) on your domain to create the rules
# Or Connect to Dialplan Web Management interface to add them manually

{| class="wikitable"
|+Table with Dial Plan Rules to create
!'''Needed for Product Type'''
!'''Compulsory'''
! '''Name'''
! '''Description'''
!'''If condition'''
!'''Then do this'''
!'''Explanation'''
|-
|Teams Connect
Teams Virtual
|{{tick|colour=green}}
|Emergency Numbers
|Allows to dial Emergency numbers
|<nowiki>^(1[0-9]|1[0-9]{2})$</nowiki>
|$1
|Allows 1x and 1xx Emergency numbers
|-
|Teams Connect
Teams Virtual
|{{tick|colour=green}}
|Short Numbers
|Allows to dial Short numbers
|<nowiki>^(3[0-9]{3}|1[0-9]{3}|11[68][0-9]{3})$</nowiki>
|$1
|Allows 3xxx + 1xxx + 116xxx + 118xxx short numbers
|-
|Teams Virtual
|optional
|Prefix-Star
|Allow VTX Feature codes using a "*" prefix
|<nowiki>^(\*\d+(\d|\*|\#)*)$</nowiki>
|$1
| Would allow any code like *<nowiki><code></nowiki>
|-
|Teams Virtual
|optional
|Prefix-Hash
|Allow disabling of VTX Feature codes using a "#" prefix
|<nowiki>^(\#(\d|\*)+)$</nowiki>
|$1
|Would allow any code like #<nowiki><code></nowiki>
|-
|Teams Virtual
|optional and to adapt
|Short number 84xx
|Call colleagues using the 4 last digits of their number
|^(84\d{2})$
| +4122879$1
|Takes a number dialed with 84xx and add "+4122879" in front of it
|-
|Teams Virtual
|optional and to adapt
|Group number 2xx
|Call VTX VPBX groups
|^(2\d{2})$
| +41228798400$1
|Takes a number dialed with 2xx and add "+41228798400" in front of it
|}

{| class="wikitable"
|+
!'''Web Admin Interface Dial Plan rule automatically added by the scripts'''
!'''Support for Short Number and Emergency Numbers integrated in Routing Creation script'''
|-
|[[File:Teams-DialPlan-Add-Compulsory-Rules-01.png|900x900px]]
|[[File:Teams-Powershell-Script-handling-Short-Numbers-01.png|none|thumb|900x900px]]
|}


==Number Mapping : Assign numbers to Microsoft accounts==
==Number Mapping : Assign/Unassign numbers to Microsoft accounts==


Now you will need to assign a number and a routing plan to each user with a "Microsoft 365 Phone System" license. You can use one of the following options to do it
Now you will need to assign a number and a routing plan to each user with a "Microsoft 365 Phone System" license. You can use one of the following options to do it
Line 91: Line 194:




=== Assign numbers using a VTX Powershell Script VTX_Teams_Assign_Numbers.ps1 ===
=== Assign/Unassign numbers using a VTX Powershell Script VTX_Teams_Assign_Numbers.ps1 ===


{{Warning|1=By default for security reason, it is not allowed to execute a powershell script downloaded on the internet, that is why you will need to open them with Wordpad to check what it does, save it and execute it afterwards}}
{{Warning|1=By default for security reason, it is not allowed to execute a powershell script downloaded on the internet, that is why you will need to open them with Wordpad to check what it does, save it and execute it afterwards}}
{{Notice|1='''2020-09-02''' : New version 1.5 of the script allows to setup several numbers at once}}


# Download https://wiki.vtx.ch/media/VTX_Teams_Assign_Numbers.ps1 on your computer ( Right Click on the link / Download )
# Download https://wiki.vtx.ch/media/VTX_Teams_Assign_Numbers.ps1 on your computer ( Right Click on the link / Download )
Line 102: Line 204:
## Your MS Admin Credentials for : ex: admin@MSDOMAIN.onmicrosoft.com
## Your MS Admin Credentials for : ex: admin@MSDOMAIN.onmicrosoft.com
## The MS Team user email : ex: first.last@MSDOMAIN.onmicrosoft.com
## The MS Team user email : ex: first.last@MSDOMAIN.onmicrosoft.com
## The Telephone number you wish to set : ex: +41225661234
## The Telephone number you wish to set : ex: +41225661234 / or leave string empty to unassign number from user




Line 118: Line 220:
</td></tr>
</td></tr>
<tr><td>
<tr><td>
[[Image:Teams-Number-Assignment-05.png|thumb|600px|left|Teams Assignment - Enter Teams User Phone Number]]
[[Image:Teams-Number-Assignment-05.png|thumb|600px|left|Teams Assignment - Enter Teams User Phone Number or use empty string to remove the number]]
</td><td>
</td><td>
[[Image:Teams-Number-Assignment-09.png|thumb|600px|left|Teams Assignment - Disable voicemail on the user ?]]
[[Image:Teams-Number-Assignment-09.png|thumb|600px|left|Teams Assignment - Disable voicemail on the user ?]]
Line 142: Line 244:


# Set Variables
# Set Variables
$MSTeamsDomain = '''"123456.teams.ipvoip.ch"'''
$TeamsDomain = '''"123456.teams.ipvoip.ch"'''
$MSTeamsUserEmail = "'''first.last@MSDOMAIN.onmicrosoft.com'''"
$TeamsUserEmail = "'''first.last@MSDOMAIN.onmicrosoft.com'''"
$MSTeamsUserNumber = '''"+41215661234"'''
$TeamsUserNumber = '''"+41215661234"'''
# Connect to Microsoft Teams management and assign number and profile to the user
# Connect to Microsoft Teams management and assign number and profile to the user
Connect-MicrosoftTeams
$Session = New-CsOnlineSession
Import-PSSession $Session -AllowClobber
# Assign a number to your user and the Call Routing
# Assign a number to your user and the Call Routing
Set-CsPhoneNumberAssignment -Identity "$TeamsUserEmail" -PhoneNumber "$TeamsUserNumber" -PhoneNumberType DirectRouting
Get-CsOnlineUser -Identity $MSTeamsUserEmail | Set-CsUser -EnterpriseVoiceEnabled $true -OnPremLineURI "tel:$MSTeamsUserNumber"
# Assign a Voice Routing Policy to your user to allow it to call out towards external numbers
# Assign a Voice Routing Policy to your user to allow it to call out towards external numbers
Get-CsOnlineUser -Identity $MSTeamsUserEmail | Grant-CsOnlineVoiceRoutingPolicy -PolicyName "CsOnlineVoiceRoutingPolicy-$MSTeamsDomain"
Grant-CsOnlineVoiceRoutingPolicy -Identity $TeamsUserEmail -PolicyName "CsOnlineVoiceRoutingPolicy-$TeamsDomain"
# Disable voicemail of the user to prevent that it answers all calls if user is not connected
# Disable voicemail of the user to prevent that it answers all calls if user is not connected
Set-CsOnlineVoicemailUserSettings -Identity $MSTeamsUserEmail -VoicemailEnabled $false
Set-CsOnlineVoicemailUserSettings -Identity $TeamsUserEmail -VoicemailEnabled $false
# Wait 60s for settings to be applied
# Wait 60s for settings to be applied
Sleep -s 60
Sleep -s 60
# Verify Your setup
# Verify Your setup
Get-CsOnlineUser -Identity $MSTeamsUserEmail | Select EnterpriseVoiceEnabled,OnPremLineURI,OnlineVoiceRoutingPolicy,RegistrarPool | Format-List
Get-CsOnlineUser -Identity $TeamsUserEmail | Select EnterpriseVoiceEnabled,OnPremLineURI,OnlineVoiceRoutingPolicy,RegistrarPool | Format-List
# List all users with EnterPrise Voice Enabled
Get-CsOnlineUser ` -Filter {(enterprisevoiceenabled -eq $true)} ` | Select sipaddress,HostedVoicemailPolicy,OnlineVoiceRoutingPolicy,lineuri | Format-List
# Logout
Disconnect-MicrosoftTeams

=== Or Unassign numbers manually in Powershell Command Prompt ===
{{Notice|1=If you prefer a manual setup, perform the following actions}}

# Open a powershell prompt on your PC
# Copy paste command below one by one changing the values in bold with your own

# Set Variables
$TeamsDomain = '''"123456.teams.ipvoip.ch"'''
$TeamsUserEmail = "'''first.last@MSDOMAIN.onmicrosoft.com'''"
$TeamsUserNumber = '''"+41215661234"'''
# Connect to Microsoft Teams management and assign or unassign number and profile to the user
Connect-MicrosoftTeams
# Unassign a number to your user and the Call Routing
Remove-CsPhoneNumberAssignment -Identity "$TeamsUserEmail" -PhoneNumber "$TeamsUserNumber" -PhoneNumberType DirectRouting
# Verify Your setup
Get-CsOnlineUser -Identity $TeamsUserEmail | Select EnterpriseVoiceEnabled,OnPremLineURI,OnlineVoiceRoutingPolicy,RegistrarPool | Format-List
# List all users with EnterPrise Voice Enabled
# List all users with EnterPrise Voice Enabled
Get-CsOnlineUser ` -Filter {(enterprisevoiceenabled -eq $true) -and(HostingProvider -eq "sipfed.online.lync.com")} ` | Select sipaddress,HostedVoicemailPolicy,OnlineVoiceRoutingPolicy,lineuri,OnPremLineURI,RegistrarPool | Format-List
Get-CsOnlineUser ` -Filter {(enterprisevoiceenabled -eq $true)} ` | Select sipaddress,HostedVoicemailPolicy,OnlineVoiceRoutingPolicy,lineuri | Format-List
# Logout
# Logout
Disconnect-MicrosoftTeams
Get-PSSession | Remove-PSSession

Latest revision as of 09:15, 21 January 2026

Connect to Microsoft 365 Admin Portal[edit | edit source]

Create a temporarily user in the <servicenumber>.teams.ipvoip.ch domain[edit | edit source]


  • Problematic: We wish to create a enableteams@<servicenumber>.teams.ipvoip.ch to enable Teams connection towards VTX VoIP platform
  • Solution: Please follow the procedure below
  1. Connect to https://admin.microsoft.com/Adminportal/Home#/users
  2. Create a new user enableteams@<servicenumber>.teams.ipvoip.ch ( First Name: "Temp User" / Last Name : "VTX Teams" / Login : enableteams@<servicenumber>.teams.ipvoip.ch / No Admin Right / "Teams" and "Phone System" licenses / No need to remember its password, we won't connect with it).
  3. Wait a few seconds/minutes/hours for Teams to be enabled on this user https://admin.microsoft.com/AdminPortal/Home#/teamsprovisioning
  4. Now even after user is created you night need to wait minutes/hours before being able to create Voice Routing ( especially the New-CsOnlineVoiceRoute ), so if you can please wait 4hours, if not, try to create the routing, if you get error, try again
  5. Once everything is working ( routing + user mapping + incoming and outgoing calls ), you can delete this user to free up the licenses

Voice Routing : Create Voice Routing to allow your users to use VTX Trunk[edit | edit source]

Now you will need to setup a routing plan. You can use one of the following options to do it

  • Using a Powershell Script that will ask you questions
  • Manually in Powershell


Microsoft Admin Center - Up to 24h Latency for each setup


Create Voice Routing using a VTX Powershell Script VTX_Teams_Create_Routing_Rules.ps1[edit | edit source]


  1. Download https://wiki.vtx.ch/media/VTX_Teams_Create_Routing_Rules.ps1 on your computer ( Right Click on the link / Download )
  2. Open it with Wordpad and use Ctrl-s to save it again ( to inform the system that it is local script )
  3. Execute it on your PC : It will ask you for these parameters and create the routing
    1. VTX Teams Domain : ex: 123456.teams.ipvoip.ch
    2. Your MS Teams Admin Credentials : ex: admin@COMPANY.onmicrosoft.com

Or Create Voice Routing manually in Powershell Command Prompt[edit | edit source]


  1. Open a powershell prompt on your PC
  2. Copy paste command below one by one changing the values in bold with your own
# Set Variables
$TeamsDomain = "123456.teams.ipvoip.ch"
# Connect to Microsoft Teams management and create all Voice Routing
Connect-MicrosoftTeams
Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="CsOnlinePstnUsage-$TeamsDomain"}
New-CsOnlineVoiceRoute -Identity "CsOnlineVoiceRoute-$TeamsDomain" -Priority 0 -NumberPattern '.*' -OnlinePstnGatewayList "$TeamsDomain" -OnlinePstnUsages "CsOnlinePstnUsage-$TeamsDomain"
New-CsOnlineVoiceRoutingPolicy -Identity "CsOnlineVoiceRoutingPolicy-$TeamsDomain" -OnlinePstnUsages "CsOnlinePstnUsage-$TeamsDomain"
Set-CsCallingLineIdentity -Identity Global -EnableUserOverride $True

# Verify all setup ( You can compare it with the Debug Section in the wiki ) 
Get-CsOnlinePstnUsage
Get-CsOnlineVoiceRoute
Get-CsOnlineVoiceRoutingPolicy
Get-CsCallingLineIdentity


# Create rule for emergency numbers (10-19, 100-199)
$emergencyRule = New-CsVoiceNormalizationRule -Identity "Global/Emergency Numbers" `
    -Pattern '^(1[0-9]|1[0-9]{2})$' `
    -Translation '$1' `
    -Description "Emergency numbers" `
    -InMemory
# Create rule for short numbers (3xxx, 1xxx, 116xxx, 118xxx)
$shortRule = New-CsVoiceNormalizationRule -Identity "Global/Short Numbers" `
    -Pattern '^(3[0-9]{3}|1[0-9]{3}|11[68][0-9]{3})$' `
    -Translation '$1' `
    -Description "Short numbers" `
    -InMemory
# Add rules to Global Dial Plan
Set-CsTenantDialPlan -Identity "Global" -NormalizationRules @{Add=$emergencyRule,$shortRule}
# Verify rules have been created
Get-CsTenantDialPlan -Identity "Global" | Select-Object Identity, NormalizationRules | Format-List

# Logout
Disconnect-MicrosoftTeams


Dial Plan for Emergency Numbers + Short Numbers + Special Setup[edit | edit source]

  • History:
    • 2026-01-21: The addition and deletion of Emergency and Short number is directly included in version 4.7+ of the create routing and delete routing script
  • Information: By default if you try to dial a number, Teams Client will always try to normalize it in +e164 mode adding your country prefix like +41 or +33 to your number
  • Problem: If you call an emergency number like 112 or a Short number like 10XX or 3XXX or 116xxx or ..., it will add an invalid country prefix
  • Problematic: Add Dial Plan entries not to alter number dialed
  • Symptoms: Within the Teams Client, you will directly see if the number you are typing is being transformed with a county prefix or not. If it is transformed, you are missing the following rules
  • Dialplan Documentation: https://docs.microsoft.com/en-US/microsoftteams/create-and-manage-dial-plans
  • Dialplan Web Admin Teams Management URL: https://admin.teams.microsoft.com/one-policy/settings/dialplan
  • Solution: Use one of the solution
  1. Run again the create routing script on last version (4.7+) on your domain to create the rules
  2. Or Connect to Dialplan Web Management interface to add them manually
Table with Dial Plan Rules to create
Needed for Product Type Compulsory Name Description If condition Then do this Explanation
Teams Connect

Teams Virtual

checkY Emergency Numbers Allows to dial Emergency numbers ^(1[0-9]|1[0-9]{2})$ $1 Allows 1x and 1xx Emergency numbers
Teams Connect

Teams Virtual

checkY Short Numbers Allows to dial Short numbers ^(3[0-9]{3}|1[0-9]{3}|11[68][0-9]{3})$ $1 Allows 3xxx + 1xxx + 116xxx + 118xxx short numbers
Teams Virtual optional Prefix-Star Allow VTX Feature codes using a "*" prefix ^(\*\d+(\d|\*|\#)*)$ $1 Would allow any code like *<code>
Teams Virtual optional Prefix-Hash Allow disabling of VTX Feature codes using a "#" prefix ^(\#(\d|\*)+)$ $1 Would allow any code like #<code>
Teams Virtual optional and to adapt Short number 84xx Call colleagues using the 4 last digits of their number ^(84\d{2})$ +4122879$1 Takes a number dialed with 84xx and add "+4122879" in front of it
Teams Virtual optional and to adapt Group number 2xx Call VTX VPBX groups ^(2\d{2})$ +41228798400$1 Takes a number dialed with 2xx and add "+41228798400" in front of it
Web Admin Interface Dial Plan rule automatically added by the scripts Support for Short Number and Emergency Numbers integrated in Routing Creation script
Teams-DialPlan-Add-Compulsory-Rules-01.png
Teams-Powershell-Script-handling-Short-Numbers-01.png

Number Mapping : Assign/Unassign numbers to Microsoft accounts[edit | edit source]

Now you will need to assign a number and a routing plan to each user with a "Microsoft 365 Phone System" license. You can use one of the following options to do it

  • Using a Powershell Script that will ask you questions
  • Manually in Powershell


Assign/Unassign numbers using a VTX Powershell Script VTX_Teams_Assign_Numbers.ps1[edit | edit source]

  1. Download https://wiki.vtx.ch/media/VTX_Teams_Assign_Numbers.ps1 on your computer ( Right Click on the link / Download )
  2. Open it with Wordpad and use Ctrl-s to save it again ( to inform the system that it is local script )
  3. Execute it on your PC : It will ask you for these parameters and create the routing
    1. VTX Teams Domain : ex: 123456.teams.ipvoip.ch
    2. Your MS Admin Credentials for : ex: admin@MSDOMAIN.onmicrosoft.com
    3. The MS Team user email : ex: first.last@MSDOMAIN.onmicrosoft.com
    4. The Telephone number you wish to set : ex: +41225661234 / or leave string empty to unassign number from user


Here is a list of screenshots to see how the script works

Teams Assignment - 1st Warning - Is routing OK ?
Teams Assignment - Enter the Teams Domain Provided by VTX
Teams Assignment - Enter Teams Admin email
Teams Assignment - Enter Teams User Email
Teams Assignment - Enter Teams User Phone Number or use empty string to remove the number
Teams Assignment - Disable voicemail on the user ?
Teams Assignment - Setup another user ?
Teams Assignment - List all user setup ?
Teams Assignment - 1st Warning - Is routing OK ?

Or Assign numbers manually in Powershell Command Prompt[edit | edit source]

  1. Open a powershell prompt on your PC
  2. Copy paste command below one by one changing the values in bold with your own
# Set Variables
$TeamsDomain = "123456.teams.ipvoip.ch"
$TeamsUserEmail = "first.last@MSDOMAIN.onmicrosoft.com"
$TeamsUserNumber = "+41215661234"
# Connect to Microsoft Teams management and assign number and profile to the user
Connect-MicrosoftTeams
# Assign a number to your user and the Call Routing
Set-CsPhoneNumberAssignment -Identity "$TeamsUserEmail" -PhoneNumber "$TeamsUserNumber" -PhoneNumberType DirectRouting
# Assign a Voice Routing Policy to your user to allow it to call out towards external numbers
Grant-CsOnlineVoiceRoutingPolicy -Identity $TeamsUserEmail -PolicyName "CsOnlineVoiceRoutingPolicy-$TeamsDomain"
# Disable voicemail of the user to prevent that it answers all calls if user is not connected
Set-CsOnlineVoicemailUserSettings -Identity $TeamsUserEmail -VoicemailEnabled $false
# Wait 60s for settings to be applied
Sleep -s 60
# Verify Your setup 
Get-CsOnlineUser -Identity $TeamsUserEmail | Select EnterpriseVoiceEnabled,OnPremLineURI,OnlineVoiceRoutingPolicy,RegistrarPool | Format-List
# List all users with EnterPrise Voice Enabled
Get-CsOnlineUser ` -Filter {(enterprisevoiceenabled -eq $true)} ` | Select sipaddress,HostedVoicemailPolicy,OnlineVoiceRoutingPolicy,lineuri | Format-List
# Logout
Disconnect-MicrosoftTeams

Or Unassign numbers manually in Powershell Command Prompt[edit | edit source]

  1. Open a powershell prompt on your PC
  2. Copy paste command below one by one changing the values in bold with your own
# Set Variables
$TeamsDomain = "123456.teams.ipvoip.ch"
$TeamsUserEmail = "first.last@MSDOMAIN.onmicrosoft.com"
$TeamsUserNumber = "+41215661234"
# Connect to Microsoft Teams management and assign or unassign number and profile to the user
Connect-MicrosoftTeams
# Unassign a number to your user and the Call Routing
Remove-CsPhoneNumberAssignment -Identity "$TeamsUserEmail" -PhoneNumber "$TeamsUserNumber" -PhoneNumberType DirectRouting
# Verify Your setup 
Get-CsOnlineUser -Identity $TeamsUserEmail | Select EnterpriseVoiceEnabled,OnPremLineURI,OnlineVoiceRoutingPolicy,RegistrarPool | Format-List
# List all users with EnterPrise Voice Enabled
Get-CsOnlineUser ` -Filter {(enterprisevoiceenabled -eq $true)} ` | Select sipaddress,HostedVoicemailPolicy,OnlineVoiceRoutingPolicy,lineuri | Format-List
# Logout
Disconnect-MicrosoftTeams