question

VinodSurvase-1595 avatar image
0 Votes"
VinodSurvase-1595 asked JimmyYang-MSFT answered

How to export private channels with name and other details like channel ID and other in bulk via powershell script ?

How to export private channels with name and other details like channel ID and other in bulk via powershell script ?

office-teams-windows-itpro
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JimmyYang-MSFT avatar image
1 Vote"
JimmyYang-MSFT answered

Hi @VinodSurvase-1595

In this blog, it provides the script about how to export only private channel information in Microsoft Teams for your reference:

 Connect-PnPOnline -Scopes ("Group.Read.All", "User.ReadBasic.All")
 $AccessToken = Get-PnPGraphAccessToken
    
 $GetAllTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $AccessToken" } -Uri "https://graph.microsoft.com/beta/groups?`$filter=resourceProvisioningOptions/any(c:c+eq+`'Team`')"
    
 $ChannelsList = @()
    
 foreach ($Team in $GetAllTeams.value) {
    
     $ResponseTeamsChannels = Invoke-RestMethod -Headers @{Authorization = "Bearer $AccessToken" } -Uri ("https://graph.microsoft.com/beta/teams/{0}/channels?`$filter=membershipType eq `'private`'" -f $Team.id)
     $ResponseTeamsChannels.value.forEach( {
     if ($_.membershipType -eq "private") {
         $ChannelObject = "" | Select-Object "TeamName", "TeamId", "ChannelName",  "ChannelId", "Description"
         $ChannelObject.TeamName = $Team.displayName
         $ChannelObject.TeamId = $Team.id
         $ChannelObject.ChannelName = $_.displayName
         $ChannelObject.ChannelId = $_.id
         $ChannelObject.Description = $_.description
         $ChannelsList += $ChannelObject
     } 
     })    
 }
    
 $ChannelsList | Export-Csv -Path './PrivateChannels.csv' -NoTypeInformation


Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.



If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.