All scripts
Microsoft 365 462
Get-TeamsCallQueueReport
Pulls every Teams call queue and auto attendant in the tenant, checks agent counts and resource account phone numbers, and flags queues that have quietly stopped working.
Get-TeamsCallQueueReport.ps1
<#
.SYNOPSIS
Reports on Microsoft Teams call queues and auto attendants, including agent counts and resource account phone number status.
.DESCRIPTION
Connects to Microsoft Teams PowerShell and pulls every call queue and auto attendant in the tenant. For each call queue it records the assigned agent count, the routing method, and the overflow and timeout thresholds. For each item it looks up the linked resource account and checks whether that account still has a phone number assigned. The report is meant to catch queues and auto attendants that quietly stopped working because a resource account lost its number or a queue was left with no agents. Results are exported to CSV and a warning is printed for anything that needs attention.
.AUTHOR
Shehryar Hassan
.EXAMPLE
.\Get-TeamsCallQueueReport.ps1 -ExportPath "C:\Reports\TeamsCallQueues.csv"
Connects to Teams, builds the report, and writes it to the given CSV path.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[string]$ExportPath = ".\TeamsCallQueueReport.csv"
)
if (-not (Get-Module -ListAvailable -Name MicrosoftTeams)) {
Write-Error "The MicrosoftTeams module is not installed. Run: Install-Module MicrosoftTeams -Scope CurrentUser"
return
}
Import-Module MicrosoftTeams -ErrorAction Stop
try {
Connect-MicrosoftTeams -ErrorAction Stop | Out-Null
}
catch {
Write-Error "Could not connect to Microsoft Teams. $_"
return
}
$results = [System.Collections.Generic.List[object]]::new()
Write-Host "Pulling call queues..."
$callQueues = Get-CsCallQueue -ErrorAction Stop
foreach ($queue in $callQueues) {
$resourceAccount = $null
if ($queue.ApplicationInstances -and $queue.ApplicationInstances.Count -gt 0) {
$raId = $queue.ApplicationInstances[0]
$resourceAccount = Get-CsOnlineApplicationInstance -Identity $raId -ErrorAction SilentlyContinue
}
$agentCount = 0
if ($queue.Agents) {
$agentCount = $queue.Agents.Count
}
$results.Add([PSCustomObject]@{
Type = "Call Queue"
Name = $queue.Name
Identity = $queue.Identity
AgentCount = $agentCount
RoutingMethod = $queue.RoutingMethod
OverflowThreshold = $queue.OverflowThreshold
TimeoutThreshold = $queue.TimeoutThreshold
ResourceAccount = if ($resourceAccount) { $resourceAccount.UserPrincipalName } else { "Not linked" }
PhoneNumberSet = if ($resourceAccount -and $resourceAccount.PhoneNumber) { "Yes" } else { "No" }
})
}
Write-Host "Pulling auto attendants..."
$autoAttendants = Get-CsAutoAttendant -ErrorAction Stop
foreach ($aa in $autoAttendants) {
$resourceAccount = $null
if ($aa.ApplicationInstances -and $aa.ApplicationInstances.Count -gt 0) {
$raId = $aa.ApplicationInstances[0]
$resourceAccount = Get-CsOnlineApplicationInstance -Identity $raId -ErrorAction SilentlyContinue
}
$results.Add([PSCustomObject]@{
Type = "Auto Attendant"
Name = $aa.Name
Identity = $aa.Identity
AgentCount = $null
RoutingMethod = $null
OverflowThreshold = $null
TimeoutThreshold = $null
ResourceAccount = if ($resourceAccount) { $resourceAccount.UserPrincipalName } else { "Not linked" }
PhoneNumberSet = if ($resourceAccount -and $resourceAccount.PhoneNumber) { "Yes" } else { "No" }
})
}
$noNumber = $results | Where-Object { $_.PhoneNumberSet -eq "No" }
if ($noNumber.Count -gt 0) {
Write-Warning "$($noNumber.Count) queue(s) or auto attendant(s) have a resource account with no phone number assigned. Callers dialing that number get nothing."
}
$emptyQueues = $results | Where-Object { $_.Type -eq "Call Queue" -and $_.AgentCount -eq 0 }
if ($emptyQueues.Count -gt 0) {
Write-Warning "$($emptyQueues.Count) call queue(s) have zero agents assigned."
}
$results | Sort-Object Type, Name | Export-Csv -Path $ExportPath -NoTypeInformation -Encoding UTF8
Write-Host "Report saved to $ExportPath"
Write-Host "Total items: $($results.Count) (Call Queues: $($callQueues.Count), Auto Attendants: $($autoAttendants.Count))"
Disconnect-MicrosoftTeams | Out-Null
Read it before you run it, and test in a safe tenant first.