Microsoft Teams

How to Report Teams Channel Storage with Microsoft Graph API and PowerShell


It’s no secret that Microsoft Teams uses SharePoint Online to store files shared between team members. Each team has a document library in the SharePoint Online site owned by the Microsoft 365 group for the team, and when a new channel is created, a folder for that channel is created within the document library.

By default, the name of the channel folder is the same as the channel. Details can be retrieved easily using Exchange Online or PnP PowerShell. However, things become more complicated when a channel is renamed.

What’s in a name?

Currently, when a channel gets renamed, its folder does not change (but hopefully will soon!) which makes finding the channel folder more difficult. Private channels create another layer of complexity because of their associated SharePoint Online site.

Within large organizations utilizing Teams, reporting on and then migrating this data is extremely difficult. To help map out how Teams uses SharePoint, I’ve created a simple Graph API / PowerShell script to report Teams channels and their SharePoint locations in a CSV file (you can download the script from GitHub here). Each channel reports the following information:

  • Team ID – The Azure AD object ID of the Team / Group
  • Team Name – The name of the Team
  • Channel Name – The name of the Channel
  • Channel Type – Whether the Channel is standard or private
  • SharePoint URL – URL of the Teams Channel storage location, including folder path
  • Storage Used (Bytes) – The current storage size of the folder

In this article I’ll walk you through the steps and show how you can run the report yourself.

Creating an App Registration

Since the script in question uses Graph API, we need an App Registration to Authenticate and Authorize our queries. To set up the registered app, you’ll want to reference this article I previously wrote for another Graph-based script.

Once you’ve done that, you need to grant the Application permissions for this script as shown in Figure 1:

How to Report Teams Channel Storage with Microsoft Graph API and PowerShell
Figure 1: Require Application Permissions

Running the Script

To run the script, you’ll need to download it to your local machine and run it in PowerShell, providing the following parameters:

  • ClientID – The Application (Client) ID of the App Registration
  • TenantID – The Directory (Tenant) ID of your Azure AD Tenancy
  • ClientSecret – A Client Secret Generated for your App Registration
  • CSVPath – The path and name for the output CSV

With the above information, the script can be run using a command as shown below:

How to Report Teams Channel Storage with Microsoft Graph API and PowerShell
Figure 2: Running the Script

If the script is run successfully, there is no output but you could always add your own progress bar for exceptionally large environments.

Review the Output

Once the script is finished, the output file should show a line entry for each Team and each Channel including the associated folder/library location and storage used. This is in CSV format so it’s easy to filter, can sort if required, and can be saved as an Excel Spreadsheet to perform some more advanced analysis.

Where the Channel Name and Type appears as “N/A,” the entry is for the Team rather than a specific channel. Check out the example output in Figure 3 to get an idea of what to expect:

How to Report Teams Channel Storage with Microsoft Graph API and PowerShell
Figure 3: Output File Example


This script is straightforward and provides information that, while not hidden, can be cumbersome to collate when attempting to utilize other tools.

This information can potentially become invaluable when auditing your cloud storage, Teams usage, or simply preparing for a migration. Having a quick and uncomplicated way to retrieve the information can make life A LOT easier.

If anything happens to be missing from the output, you can customize the script to add it in. As always, make sure before running and test any code in your production environment prior, so you completely understand what it will do.

Source Practical 365

Chioma Ugochukwu

The author Chioma Ugochukwu

Leave a Response