/errors/teams/set-csphonenumberassignment-missing-numbertype
Cannot process command because of one or more missing mandatory parameters: NumberType (Teams phone)
- tool
- Microsoft Teams PowerShell
- exit code
- 1
- versions
- MicrosoftTeams 8.0.0, Windows PowerShell 5.1
- os
- windows, linux, macos
Set-CsPhoneNumberAssignment : Cannot process command because of one or more missing mandatory parameters: NumberType. means you passed a user and a phone number but not the number type. To assign a number to a user or resource account, all three are required:
Set-CsPhoneNumberAssignment -Identity user1@contoso.com -TelephoneNumber +12065551234 -NumberType CallingPlanUse DirectRouting, CallingPlan or OperatorConnect, depending on where the number comes from. -PhoneNumber and -PhoneNumberType are aliases of the two parameters, so scripts using those names fail the same way. Connect with Connect-MicrosoftTeams first; assigning numbers needs the Teams Administrator or Teams Telephony Administrator role.
Reproduce it
In a non-interactive session (as scripts run) PowerShell reports the missing parameter instead of prompting for it. MicrosoftTeams 8.0.0, no connection needed:
Import-Module MicrosoftTeams
try {
Set-CsPhoneNumberAssignment -Identity user1@contoso.com -TelephoneNumber +12065551234 -ErrorAction Stop
} catch {
$_.Exception.Message
$_.FullyQualifiedErrorId
}
'Aliases of -TelephoneNumber: ' + ((Get-Command Set-CsPhoneNumberAssignment).Parameters['TelephoneNumber'].Aliases -join ', ')
'Aliases of -NumberType: ' + ((Get-Command Set-CsPhoneNumberAssignment).Parameters['NumberType'].Aliases -join ', ')Output
Cannot process command because of one or more missing mandatory parameters: NumberType. MissingMandatoryParameter,Set-CsPhoneNumberAssignment Aliases of -TelephoneNumber: PhoneNumber Aliases of -NumberType: PhoneNumberType
In an interactive console PowerShell asks Supply values for the following parameters: NumberType: instead.
Parameter sets
| Goal | Command |
|---|---|
| Assign a number to a user | Set-CsPhoneNumberAssignment -Identity USER -TelephoneNumber +E164 -NumberType CallingPlan |
| Assign with an emergency location | add -LocationId (Get-CsOnlineLisLocation -City Vancouver).LocationId |
| Direct Routing number with extension | Set-CsPhoneNumberAssignment -Identity USER -TelephoneNumber "+1206555000;ext=1234" -NumberType DirectRouting |
| Only enable Enterprise Voice | Set-CsPhoneNumberAssignment -Identity USER -EnterpriseVoiceEnabled $true |
| Remove the number | Remove-CsPhoneNumberAssignment -Identity USER -TelephoneNumber +E164 -NumberType CallingPlan |
The number can be given as +12065551234 or 12065551234, without a tel: prefix. Assigning a number also sets EnterpriseVoiceEnabled to $true.
Check the assignment
Get-CsOnlineUser -Identity user1@contoso.com | Format-List LineUri,EnterpriseVoiceEnabled
Get-CsPhoneNumberAssignment -AssignedPstnTargetId user1@contoso.com