Get Teams, Channels, Tabs, and Privacy Settings using Teams PnP PowerShell

In case you haven’t seen, Teams PnP PowerShell cmdlets are starting to surface! 🥳

In this short blog post, we’ll have a look at how to export a list of:

  • Teams
  • Channels
  • Tabs
  • Privacy Settings (Public or Private Teams)

Let’s dive in!

 

Connect to Teams PnP PowerShell

I’m not really going to go over this because all is explained in Erwin’s post.
But I am going to give you a tip or two from the only issue I had when connecting.

The first time, you need to add your App ID when using the Connect-PnPOnline -Scopes "Group.ReadWrite.All"
And you may have an error that the URL is not the one expected: “Sorry, we can’t sign you in…“. If you’re using Edge Chromium with multiple profiles, you’re probably on the wrong one.

In that case, just close your browser (or even both with your PowerShell console), and make sure to run Connect-PnPOnline -Scopes "Group.ReadWrite.All" with the right profile opened.

If the pop-up window is blank, just wait for a few seconds, and it’ll ask you to sign in 😉

 

Get me the data!

OK, OK! We’re going to use 3 different cmdlets:

 

Note: Just change <YOUR_PATH> at the end to your own value.

## Connect to Teams PnP
Connect-PnPOnline -Scopes "Group.ReadWrite.All" -Credentials "msftdemo"

#Store variables
$results = @()
$allTeams = Get-PnPTeamsTeam

#Loop through each Team
foreach($team in $allTeams){
    $allChannels = Get-PnPTeamsChannel -Team $team.DisplayName
    
    #Loop through each Channel
    foreach($channel in $allChannels){
        $allTabs = Get-PnPTeamsTab -Team $team.DisplayName -Channel $channel
        
        #Loop through each Tab + get the info!
        foreach($tab in $allTabs){
            $results += [pscustomobject][ordered]@{
                Team = $team.DisplayName
                Visibility = $team.Visibility
                ChannelName = $channel.DisplayName
                tabName = $tab.DisplayName
            }
        }
    }
}
$results | Export-Csv -Path <YOUR_PATH> -NoTypeInformation

 

As usual, the properties are up to you, and you can decide using Get-Member.

 

Export results

After a few clicks… Tada! 😇

Note that the “Posts” and “Files” tabs are not showing because you can’t change / remove them.

 

Thanks for reading!

 

 

Leave a Reply

%d bloggers like this: