Microsoft recently released the ability to programmatically retrieve Microsoft Teams PSTN Usage records using the Graph API. This data is currently available in the Teams admin center under Analytics & reports > Usage reports > PSTN & SMS usage. However, performing additional analysis on the data required manually exporting to a CSV file, and who wants to do that?

Enter the TeamsCloudCommunicationApi module.

Inspired by Lee Ford’s Get-TeamsPSTNCallRecords script, I wrote my own module to work with the Graph API to retrieve these records. I approached the solution a bit differently:

  • Ability to create and use a Graph API access token without storing client secret in the script
  • Separate commands for retrieving calling plan and direct routing call records
  • Use Export-Csv or ConvertTo-Json to export the data to the format you want. Or just let it output to the console window.
  • Specify Start and End dates or the last number of days to retrieve records

Check out the module code and some how-to instructions on setting up the Azure application registration, importing the module, and some example commands:

GitHub: JeffBrownTech/TeamsCloudCommunicationApi

You can download the module directly from the PowerShell Gallery using the following command:

Install-Module -Name TeamsCloudCommunicationApi

This Graph API is currently under beta and not recommended for production, so use at your own risk. You can find more information on the Cloud Communication API here:
Microsoft Docs: Working with communications API in Microsoft Graph

Questions or comments? If so, drop me a note below or find me on Twitter or LinkedIn to discuss further.

Leave a Reply