This article serves as documentation for the script, which is stored on GitHub.
The corresponding script can be downloaded from the following link.

It is often the case that we have to adapt the Team Calling Policies for several users. This can be done in two ways.

  • via the Microsoft Teams Admin Center
  • via PowerShell

This documentation deals with the second option.

 

In order to use the script described here, we first need a corresponding extract of all known users that are available in the Azure Active Directory.
In the best case, this export should be exported directly into a CSV file, which we can then use further.

As an example of how such a PowerShell export can look, I have shown it below:

 

# Split path
$Path = Split-Path -Parent "D:\Users\Documents\MDM\TCP\BoB\*.*"

# Create variable for the date stamp in log file
$LogDate = Get-Date -f yyyyMMddhhmm

# Define CSV and log file location variables
# They have to be on the same location as the script
$Csvfile = $Path + "\AllAzADUsers_$logDate.csv"

# Get all Azure AD users
$AzADUsers = Get-AzureADUser -All $true | Select-Object -Property *

# Display progress bar
$progressCount = 0
for ($i = 0; $i -le $AzADUsers.Count; $i++) {

Write-Progress `
-Id 0 `
-Activity "Retrieving User " `
-Status "$progressCount of $($AzADUsers.Count)" `
-PercentComplete (($progressCount / $AzADUsers.Count) * 100)

$progressCount++
}

# Create list
$AzADUsers | Sort-Object GivenName | Select-Object `
@{Label = "DisplayName"; Expression = { $_.DisplayName } },
@{Label = "UserPrincipalName"; Expression = { $_.UserPrincipalName } },
@{Label = "TelephoneNumber"; Expression = { $_.TelephoneNumber } },
@{Label = "CallingPolicy"; Expression = { if (($_.AccountEnabled -eq 'True') ) { 'Enabled' } Else { 'Disabled' } } } |

# Export report to CSV file
Export-Csv -Encoding UTF8 -Path $Csvfile -NoTypeInformation #-Delimiter ";"

 

After we have the export in the CSV, we check the content of this CSV. On the one hand, we adjust the users for whom we want to set a calling policy and delete all relevant users.
The second step is to replace the values “Enabled” or “Disabled” in the export file under the heading “CallingPolicy” with the name of the desired policy. (As an example: BusyonBusy).

After this is done, we can run the script from Github.

First, we need to log in to the appropriate Teams Tenant via PowerShell. We do this with the command:

Connect-MicrosoftTeams

Then we run the script without any modifications.

While the script is being executed, we are asked to select a CSV file that has been provided according to the specifications in the script.
Here we select the previously prepared CSV file, confirm the import and execute it.

Subsequently, the desired calling policies are set as they have been defined.

 

As always, this script is available for free to anyone who needs it. You can download it from my GitHub repository and use it.

Also, as always, I assume no responsibility for possible misconfigurations and strongly recommend using the first run of this script in a LAB or test environment.

This script can be used and adapted indefinitely, but not sold to third parties.

Link to the Script on GitHub