Remove-CsPhoneNumberAssignment
Removes or unassigns a phone number from a user or resource account (online application instance).
Syntax
RemoveSome (Default)
Remove-CsPhoneNumberAssignment
-Identity <String>
-TelephoneNumber <String>
-NumberType <String>
[-HttpPipelinePrepend <SendAsyncStep[]>]
[-Notify]
[-AssignmentBlockedForever]
[-AssignmentBlockedDays <Integer>]
[<CommonParameters>]
RemoveAll
Remove-CsPhoneNumberAssignment
-Identity <String>
[-HttpPipelinePrepend <SendAsyncStep[]>]
[-RemoveAll]
[-Notify]
[<CommonParameters>]
Description
This cmdlet removes or unassigns a phone number from a user or resource account. The phone number continues to be available in the tenant unless you block assignment by using AssignmentBlockedForever or AssignmentBlockedDays.
Unassigning a phone number from a user or resource account automatically sets EnterpriseVoiceEnabled to False.
If the cmdlet executes successfully, no result object is returned. If the cmdlet fails for any reason, a result object is returned that contains a Code string parameter and a Message string parameter with additional details about the failure. Email notification to the end user is a best-effort operation. No error message is displayed if the email fails to send.
Note: In Teams PowerShell module 4.2.1-preview and later, the cmdlet reports errors differently. Instead of returning a result object, the cmdlet generates an exception and appends it to the $Error automatic variable. The cmdlet also supports the ErrorAction parameter to control execution after an error occurs.
Examples
Example 1
Remove-CsPhoneNumberAssignment -Identity user1@contoso.com -TelephoneNumber +12065551234 -NumberType CallingPlan
This example removes or unassigns the Microsoft Calling Plan telephone number +1 (206) 555-1234 from the user user1@contoso.com.
Example 2
Remove-CsPhoneNumberAssignment -Identity user2@contoso.com -RemoveAll
This example removes or unassigns all telephone numbers from user2@contoso.com.
Example 3
Remove-CsPhoneNumberAssignment -Identity user1@contoso.com -TelephoneNumber +12065551234 -NumberType CallingPlan -Notify
This example removes or unassigns the Microsoft Calling Plan phone number +1 (206) 555-1234 from the user user1@contoso.com and sends an email notification to the user about the removal.
Example 4
Remove-CsPhoneNumberAssignment -Identity user2@contoso.com -RemoveAll -Notify
This example removes or unassigns all telephone numbers from user2@contoso.com and sends an email notification to the user about the change.
Example 5
Remove-CsPhoneNumberAssignment -Identity user1@contoso.com -TelephoneNumber +12065551234 -NumberType CallingPlan -AssignmentBlockedForever
This example removes a telephone number assignment from user1@contoso.com and sets an assignment block on the unassigned number for an indefinite duration.
Example 6
Remove-CsPhoneNumberAssignment -Identity user1@contoso.com -TelephoneNumber +12065551234 -NumberType CallingPlan -AssignmentBlockedDays 30
This example removes a telephone number assignment from user1@contoso.com and sets an assignment block on the unassigned number for 30 days. The telephone number isn't available for new assignment for 30 days or until the block is removed manually. The telephone number automatically becomes available for assignment after the 30-day period ends.
Parameters
-AssignmentBlockedDays
Sets a duration-based assignment block on the telephone number. The value must be an integer from 1 through 365.
Parameter properties
| Type: | System.Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-AssignmentBlockedForever
Sets an indefinite block on assignment for the telephone number.
Parameter properties
| Type: | System.Management.Automation.SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-HttpPipelinePrepend
Specifies SendAsync pipeline steps to prepend to the generated HTTP pipeline.
Parameter properties
| Type: | Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Runtime.SendAsyncStep[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-Identity
The identity of the specific user or resource account. You can specify the ObjectId, SipProxyAddress, or UserPrincipalName attribute of the user or resource account.
Parameter properties
| Type: | System.String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-Notify
Sends a best-effort email notification when a phone number is removed. Failures to send email are not reported.
Parameter properties
| Type: | System.Management.Automation.SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-NumberType
The type of phone number to unassign from the user or resource account. The supported values are DirectRouting, CallingPlan, and OperatorConnect.
Parameter properties
| Type: | System.String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | PhoneNumberType |
Parameter sets
RemoveSome
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-RemoveAll
Unassigns all phone numbers from the user or resource account.
Parameter properties
| Type: | System.Management.Automation.SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
RemoveAll
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-TelephoneNumber
The phone number to unassign from the user or resource account. Supports E.164 and non-E.164 formats. The phone number can't have a "tel:" prefix.
Parameter properties
| Type: | System.String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | PhoneNumber |
Parameter sets
RemoveSome
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
None
Outputs
System.Object
Notes
The cmdlet is available in Teams PowerShell module 3.0.0 or later. The Notify parameter was introduced in Teams PowerShell module 7.3.0. The AssignmentBlockedForever and AssignmentBlockedDays parameters were introduced in Teams PowerShell module 7.5.0.