Powershell to export Teams Call Queue

MS 426 Reputation points
2022-04-01T19:30:07.373+00:00

Would you please help me to get the PowerShell script to pull out the following information into a CSV file in the proper format for "Teams Call Queues"
We have around 3+ Lakhs users count and the script should run with the Teams Module 4.0.0.

SipAddress
QueueID
QueueName
QueueAllowOptOut
QueuePresenceBasedRouting
UserPrincipalName
LineUri
QueueConferenceMode
QueueRoutingMethod

Thanks in Advance..!

Regards,
MS

Windows for business | Windows Server | User experience | PowerShell
Microsoft Teams | Microsoft Teams for business | Other
{count} votes

2 answers

Sort by: Most helpful
  1. MS 426 Reputation points
    2022-04-04T20:00:43.74+00:00

    Hi @Yuki Sun-MSFT

    Thanks for the support, basically we are using the following script to export the required parameters into the CSV using Teams module 2.3.1, but the script is not working in 4.0.0,
    It would be great if you can check and resolve the issue. I can run this script individually and get the output in 4.0.0, but when I run the complete script Script.Ps1 I get the following error.

    Here is the error:
    189819-image.png


    $transscriptname = "CallAgents" + (Get-Date ` -Format s).replace(":","-") +".txt"

    Start-Transcript $transscriptname

    $cq = Get-CsCallQueue -First 5000

    $users = @()

    foreach($q in $cq){$queueUsers = $q.Users

    foreach($user in $queueusers){  
    
                    $agent = Get-CsOnlineUser -Identity $user.Guid | Select UserPrincipalName, LineUri, SipAddress  
                            
                    $props = @{  
                        QueueName = $q.Name  
                        QueueID = $q.Identity  
                        QueueRoutingMethod = $q.RoutingMethod  
                        QueueAllowOptOut = $q.AllowOptOut  
                        QueueConferenceMode = $q.ConferenceMode  
                        QueuePresenceBasedRouting = $q.PresenceBasedRouting  
                        UserPrincipalName = $agent.UserPrincipalName  
                        LineUri = $agent.LineUri  
                        SipAddress = $agent.SipAddress  
                    }  
    
                    $userObject = New-Object -TypeName PSObject -Property $props  
                    $users += $userObject  
                  
                }         
    

    }

    $users | Export-Csv c:\CallQueueAgents.csv

    Stop-Transcript


    Thank you,

    MS


  2. Rich Matheisen 47,901 Reputation points
    2022-04-05T15:17:55.283+00:00

    Is that the call queue object you're looking at or a cs user object? The cmdlet that reports the error is Get-CsOnlineUser. You need the GUID of the user.

    When you examine the "Users" property of the queue, what do you see?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.