List All Teams and Channels

In this article I am going to show you how to list all Microsoft Teams and Channels in an Microsoft 365 tenant. I will show two approaches to export this information as a csv file: PowerShell vs Power Automate.


This question from PatrickJMcLean:

I am building a flow to collect all the Teams in our 365 Tenant, and any channels within those Teams. I have no problem exporting the Teams to a table in Excel, but the problem comes when I try to export the channels.

Power Users Community thread: Extracting All Teams and Their Channels.


First of all you could retrieve this information with Microsoft Teams PowerShell. This module contains the Get-Team & Get-TeamChannel cmdlets. Below is a PowerShell script based on a sample from gcjuw84 on Techcommunity forums. Feel free to use the PowerShell script if your more a cmd line type of person.

Graph API

However, in this case I also tried to solve it via Power Automate, just for the challenge ;). Within this Power Automate flow the List all teams in Microsoft Teams for an organization and the List Channels methods of the Graph API are used.

The flow steps

Before you start:
1. This sample assumes the account used has Global admin or Microsoft Teams admin permissions
2. Be aware the HTTP action is part of a premium connector.
3. The HTTP actions use Active Directory OAuth authentication.

You need to register an App in Azure Active Directory with the appropriate scope permissions. Like mentioned in a couple of my other blogposts, Elaiza Benitez has written a nice blogpost about this, How to authenticate as an application with Microsoft Graph API with flow.


1. Add a Recurrence trigger action.

This flow will run once a week on Monday at 07:00.


a. Select an Interval, in this setup 1
b. Select the Frequency, in this setup Week
c. Select the Days, in this setup Monday
d. Select the Hours, in this setup 07

2. Add a Initialize variable action.

This array is used to temporary store all the details from the GET actions.


a. Provision a Name for the variable, in my setup AllTeamsandChannelsArray
b. Select the Array Type

3. Add a HTTP action.
This action is to retrieve all the Teams via the Graph API.


a. Select the GET method
b. Use the URI from the codesnippet below
c. Use the Headers from the codesnippet below
d. Select Active Directory OAuth for the Authentication, provide the details of your Azure AD App.

4. Add a Apply to Each action.
This action is to loop through the collection of teams and retrieve all the channels per team.


a. Use the body/value for the Select an output from previous steps.

5. Add a second HTTP action (within the Apply to Each action).
In this HTTP action we use TeamId to retrieve the channels per team


a. Select the GET method
b. Use the URI from the codesnippet below
c. Use the Headers from the codesnippet below
d. Select Active Directory OAuth for the Authentication, provide the details of your Azure AD App.

6. Add a Select action (within the Apply to Each action).
In this action we will collect both details of the Team and of the Channel. Every Channel will have it’s own row in the CSV file.


a. Use the body/value from the previous HTTP action in the From field.
b. Switch the Map field to text mode
c. Use the codesnippet below in the Map field

7. Add a Compose action (within the Apply to Each action).
A union function is used to add all array items into one single Array from our array variable.


a. Use the expression from the codesnippet below for the inputs

8. Add a Set Variable action (within the Apply to Each action).
In this action we will store the output from the compose into the variable.


a. Select the AllTeamsandChannelsArray variable
b. Use the Outputs of the Compose action for the Value field.

9. Add a Create CSV table action.
From the Array variable a CSV table is generated.


a. Use the AllTeamsandChannelsArray for the From field.

10. Add a Create file action.
The CSV table content will be used to create a file. In this case on SharePoint, but OneDrive for Business would be another option.


a. Select the SharePoint Site where you want to store the file.
b. Select the Folder Path
c. Provide a file name, I used the following expression: d. Use the Output of the Create CSV table in the File Content field.


That is it for the setup of this example.

The output when you run the flow or the PowerShell script should look something like below. createfile_teams_output

Happy testing!

You may also like...

7 Responses

  1. Sören says:

    Hi Dennis, thanks for the great tutorial. Could you explain step 4 in more detail? I followed your guide closely, but in the first ‘Apply to each’ step, I can only select the ‘body’ as the output from the previous step.
    How do you apply your comment: body('HTTP_-_List_All_Teams')['value']

    Thanks, Sören

  2. Dennis says:

    Hi Sören,

    I have added it as an expression instead of selecting it as a dynamic content field.

  3. Matthew says:

    Thank you for the powershell it worked!!

  4. Dennis says:

    Hi Matthew,

    Great to hear that solution approach worked for you.

  5. lee says:

    Hi, really interested to use this but the PS give me an error
    TerminatingError(Get-TeamChannel): “Cannot bind argument to parameter ‘GroupId’ because it is null.”
    any ideas?

  6. Dennis says:

    Hi Lee,

    That error suggests that it has found a team without a GroupId, which is kind of odd.

    I would only run the Get-Team cmdlet and see what your PowerShell outputs. Should be a list of all your Teams including the GroupId field.

    Which version of the MicrosoftTeams PowerShell Module did you use btw?

  7. Powershell Noob says:

    Hi – Incredible, thank you for this!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.