How to Export List of All Private Channels for Single User in Teams

Vikram 1 Reputation point
2022-11-24T17:57:27.1+00:00

Is there any Teams PowerShell command to get list of all Private channels one user is member of.
Ex: I need to know user - 123@jaswant .com is member of what Private Channels.
And then next day I want to add those same Private Channels to a different user 456@xyz .com.

Microsoft Teams | Microsoft Teams for business | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JimmyYang-MSFT 58,641 Reputation points Microsoft External Staff
    2022-11-25T09:56:43.777+00:00

    Hi @Vikram

    I have found a script about how to get a list of all Teams with associated channels.

     # Connect to Microsoft Teams  
           
     Connect-MicrosoftTeams  
           
     # List all Teams and all Channels  
           
     $ErrorActionPreference = "SilentlyContinue"  
           
     $allteams = Get-Team  
     $object = @()  
           
     foreach ($t in $allteams) {  
           
         $members = Get-TeamUser -GroupId $t.GroupId  
           
         $owner = Get-TeamUser -GroupId $t.GroupId -Role Owner  
           
         $channels = Get-TeamChannel -GroupId $t.GroupId   
           
         $object += New-Object -TypeName PSObject -Property ([ordered]@{  
           
             'Team'= $t.DisplayName  
             'GroupId' = $t.GroupId  
             'Owner' = $owner.User  
             'Members' = $members.user -join "`r`n"  
             'Channels' = $channels.displayname -join "`r`n"  
               
             })  
                   
     }  
     Write-Output $object  
    

    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.


    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.