Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions teams/teams-ps/MicrosoftTeams/Get-CsPhoneNumberPolicyAssignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
applicable: Microsoft Teams
author: pavellatif
external help file: Microsoft.Teams.ConfigAPI.Cmdlets-help.xml
Locale: en-US
manager: roykuntz
Module Name: MicrosoftTeams
ms.author: pavellatif
ms.reviewer: pavellatif
online version: https://learn.microsoft.com/powershell/module/microsoftteams/get-csphonenumberpolicyassignment
schema: 2.0.0
title: Get-CsPhoneNumberPolicyAssignment
---

# Get-CsPhoneNumberPolicyAssignment

## SYNOPSIS
This cmdlet retrieves policy assignments associated with a specific telephone number or a list of telephone numbers in Microsoft Teams.

## SYNTAX
Policy assignment for individual telephone number:
```
Get-CsPhoneNumberPolicyAssignment [-TelephoneNumber <String>]
[<CommonParameters>]
```

Policy assignment info for a list of numbers with specific policy.
```
Get-CsPhoneNumberPolicyAssignment [-PolicyType <String>] [-PolicyName <String>] [-ResultSize <Int32>]
[<CommonParameters>]
```

## DESCRIPTION
This cmdlet retrieves policy assignments associated with one or more telephone numbers. It supports querying a single telephone number or a list of numbers, with optional filtering by policy type or policy name. This functionality is particularly useful for administrators managing Teams voice configurations, including scenarios with multiline support.

When querying a single telephone number, the cmdlet returns the most recent effective policy assignment. Note that it may take several minutes for newly applied assignments to propagate and appear in the results.

## EXAMPLES

### Example 1
Policy assignment for individual telephone number

```powershell
PS C:\> Get-CsPhoneNumberPolicyAssignment -TelephoneNumber 17789493766
```
```output
TelephoneNumber PolicyType PolicyName Authority AssignmentType Reference
--------------- ---------- ---------- --------- -------------- ---------
17789493766 TenantDialPlan PolicyFoo Tenant Direct Direct
17789493766 CallingLineIdentity PolicyBar Tenant Direct Direct
```
This example returns all policy assigned for the specified telephone number.


### Example 2
List of telephone numbers with any policy assigned

```powershell
PS C:\> Get-CsPhoneNumberPolicyAssignment
```
```output
TelephoneNumber PolicyType PolicyName Authority AssignmentType Reference
--------------- ---------- ---------- --------- -------------- ---------
1234567 TenantDialPlan BenTestPolicy Tenant Direct Direct
17789493766 TenantDialPlan PolicyFoo Tenant Direct Direct
17789493766 CallingLineIdentity PolicyBar Tenant Direct Direct
```
This example returns a list of all the telephone numbers in the tenant that have at least one policy assigned.

### Example 3
Policy assignment info for a list of numbers with specific policy type

```powershell
PS C:\> Get-CsPhoneNumberPolicyAssignment -PolicyType TenantDialPlan
```
```output
TelephoneNumber PolicyType PolicyName Reference
--------------- ---------- ---------- ---------
1234567 TenantDialPlan BenTestPolicy Direct
17789493766 TenantDialPlan PolicyFoo Direct
```
This example returns a list of all the telephone numbers in tenant that have TenantDialPlan assigned.

### Example 4
Policy assignment info for a list of numbers filtered by policy type, policy name, and count

```powershell
PS C:\> Get-CsPhoneNumberPolicyAssignment -PolicyType TenantDialPlan -PolicyName PolicyFoo -ResultSize 1
```
```output
TelephoneNumber PolicyType PolicyName Reference
--------------- ---------- ---------- ---------
17789493766 TenantDialPlan PolicyFoo Direct
```
This example returns the top 1 telephone number with policy assignment matching the specified type and name.


## PARAMETERS

### -TelephoneNumber
Specifies the telephone number to query.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases: Identity

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PolicyType
Filters results by the type of policy assigned (e.g., TenantDialPlan, CallingLineIdentity etc.).

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PolicyName
Filters results by the name of the policy.
To use this parameter, `-PolicyType` must also be specified.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ResultSize
Limits the number of telephone numbers returned in the results.

```yaml
Type: System.Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### 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](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

### TelephoneNumber
The telephone number.

### PolicyType
The type of the policy assigned to the telephone number.

### PolicyName
The name of the policy assigned to the telephone number.

### Reference
Metadata that describes the origin or mechanism of the policy assignment. It helps administrators understand whether a policy was explicitly set or inherited through broader configuration scopes. This cmdlet returns only Direct assignments, which are policies that are explicitly assigned to telephone numbers by a tenant admin.

## NOTES
The cmdlet is available in Teams PowerShell module 7.3.1 or later.
The cmdlet is only available in commercial cloud instances.

## RELATED LINKS

[Set-CsPhoneNumberPolicyAssignment](./set-csphonenumberpolicyassignment.md)
6 changes: 6 additions & 0 deletions teams/teams-ps/MicrosoftTeams/MicrosoftTeams.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ Use the `Get-CsOnlineVoiceUser` cmdlet to retrieve a voice user's telephone numb
### [Get-CsPhoneNumberAssignment](Get-CsPhoneNumberAssignment.md)
This cmdlet displays information about one or more phone numbers.

### [Get-CsPhoneNumberPolicyAssignment](Get-CsPhoneNumberPolicyAssignment.md)
This cmdlet retrieves policy assignments associated with a specific telephone number or a list of telephone numbers in Microsoft Teams.

### [Get-CsPhoneNumberTag](Get-CsPhoneNumberTag.md)
This cmdlet allows the admin to get a list of existing tags for telephone numbers.

Expand Down Expand Up @@ -1457,6 +1460,9 @@ Use the `Set-CsOnlineVoiceUser` cmdlet to set the PSTN specific parameters (like
### [Set-CsPhoneNumberAssignment](Set-CsPhoneNumberAssignment.md)
This cmdlet will assign a phone number to a user or a resource account (online application instance).

### [Set-CsPhoneNumberPolicyAssignment](Set-CsPhoneNumberPolicyAssignment.md)
This cmdlet assigns a policy to a specific telephone number in Microsoft Teams.

### [Set-CsPhoneNumberTag](Set-CsPhoneNumberTag.md)
This cmdlet allows the admin to create and assign a tag to a phone number.

Expand Down
125 changes: 125 additions & 0 deletions teams/teams-ps/MicrosoftTeams/Set-CsPhoneNumberPolicyAssignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
applicable: Microsoft Teams
author: pavellatif
external help file: Microsoft.Teams.ConfigAPI.Cmdlets-help.xml
Locale: en-US
manager: roykuntz
Module Name: MicrosoftTeams
ms.author: pavellatif
ms.reviewer: pavellatif
online version: https://learn.microsoft.com/powershell/module/microsoftteams/set-csphonenumberpolicyassignment
schema: 2.0.0
title: Set-CsPhoneNumberPolicyAssignment
---

# Set-CsPhoneNumberPolicyAssignment

## SYNOPSIS
This cmdlet assigns a policy to a specific telephone number in Microsoft Teams.

## SYNTAX
```
Set-CsPhoneNumberPolicyAssignment [-TelephoneNumber <String>] [-PolicyType <String>] [-PolicyName <String>]
[<CommonParameters>]
```

## DESCRIPTION
The cmdlet assigns a policy to a telephone number in Microsoft Teams. This is useful in multi-line scenarios or when managing voice configurations for users who require specific dial plans or calling policies for different telephone numbers.

Please note that policies must be pre-created and available in the tenant before assignment. The list of policies that can be assigned to telephone numbers are:
- CallingLineIdentity
- OnlineDialOutPolicy
- OnlineVoiceRoutingPolicy
- TeamsEmergencyCallingPolicy
- TeamsEmergencyCallRoutingPolicy
- TeamsSharedCallingRoutingPolicy
- TenantDialPlan

Assignments are effective immediately, but may take a few minutes to propagate and show up in results in [Get-CsPhoneNumberPolicyAssignment](./get-csphonenumberpolicyassignment.md) cmdlet.


## EXAMPLES

### Example 1
```powershell
PS C:\> Set-CsPhoneNumberPolicyAssignment -TelephoneNumber 17789493766 -PolicyType TenantDialPlan -PolicyName "US Admins Dial Plan"
```
This example assigns a policy to the specified telephone number.

### Example 2
```powershell
PS C:\> Set-CsPhoneNumberPolicyAssignment -TelephoneNumber 17789493766 -PolicyType TenantDialPlan
```
This example removes an existing TenantDialPlan previously assigned to the specified telephone number.


## PARAMETERS

### -TelephoneNumber
Specifies the telephone number to which the policy will be assigned.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases: Identity

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PolicyType
Indicates the type of policy being assigned.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PolicyName
The name of the policy to assign. This must match an existing policy configured in the tenant.

If the telephone number already has a different policy of the same PolicyType assigned, then this will replace the existing policy assignment.

If PolicyName is not provided, then it would remove any existing policy of the same PolicyType previously assigned to the specified phone number.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### 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](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

This cmdlet does not return output on success. Errors are thrown if the assignment fails due to invalid parameters, missing policies, or internal service issues.

If you want to verify the outcome of the assignment, call `Get-CsPhoneNumberPolicyAssignment -TelephoneNumber <YourPhoneNumber>`.

## NOTES
The cmdlet is available in Teams PowerShell module 7.3.1 or later.
The cmdlet is only available in commercial cloud instances.

## RELATED LINKS
[Get-CsPhoneNumberPolicyAssignment](./get-csphonenumberpolicyassignment.md)