Forum Discussion

Youness022's avatar
Youness022
Copper Contributor
Apr 06, 2022

Listing all private channels and owners

I would like to get a list of all private channels and their owners, is there a way to do it?

 

Thanks

4 Replies

  •  

     

    Hello Youness022  

    Did this quickly, it can be improved but it does what you want

     

     

    Connect-MicrosoftTeams
    
    $Teams = Get-Team
    
    foreach($team in $teams){
    
    $PrivateChannel=Get-TeamChannel -MembershipType private -GroupId $team.groupId
    
    if($privateChannel)
    {
    Write-Host "Private Channel: " $privateChannel.displayName
    
    $owner=Get-TeamChannelUser -Role owner -GroupId $team.groupId -DisplayName $privateChannel.displayName
    
    Write-Host "Owner: " $owner.Name
    }
    
    }

     

    • stephen_black1915's avatar
      stephen_black1915
      Copper Contributor

      AndresGorzelany 

      So Close - thanks for the starter.

      
      Connect-MicrosoftTeams
      $teamName = Read-Host -Prompt 'Team name?'
      $Teams = Get-Team -DisplayName $teamName
      foreach($team in $teams){
      Write-Host "Team: " $team.displayName
      $privateChannels=Get-TeamChannel -MembershipType private -GroupId $team.groupId
      foreach($privateChannel in $privateChannels)
      {
      Write-Host "Private Channel: " $privateChannel.displayName
      $owners=Get-TeamChannelUser -Role owner -GroupId $team.groupId -DisplayName $privateChannel.displayName
      foreach($owner in $owners){
          Write-Host "Owner: " $owner.Name
      }
      }
      }
    • abyutd's avatar
      abyutd
      Copper Contributor
      What version are you using for Teams PowerShell?

Resources