Powershell scripts Find your teams with private channels with PowerShell script January 17, 2023 By: Syskit team Last updated: June 27, 2023 3 min read Scratching your head over finding a list of all your teams with private channels? Look no further than this PowerShell script! Finding the ideal solution to this problem has never been easier. Table of contents Find teams with private channels: script codeGet a list of teams with private channels quickly with Syskit Point This PowerShell script helps users locate all teams with private channels by querying and checking each one. It produces a detailed output that includes each team and its private channels. It also offers lists of all channel members and owners. For your convenience, the output is displayed on the screen by default. You may also use one of the optional flags to export the result to CSV. -ExportCSV (if set, this will automatically export the result to a CSV file. If no export path is set, it will export the file to %temp% folder) Example: Get-TeamsWithPrivateChannels.ps1 -ExportCSV -ExportFilePath Example: Get-TeamsWithPrivateChannels.ps1 -ExportCSV -ExportFilePath “C:Tempreport.csv” Just focus on collaborating with your team while our script takes care of finding the private channels. Find teams with private channels: script code #Owners, Members, channeldid and csv export) # Set script parameters [CmdletBinding()] param ( [switch]$ExportCSV, [string]$ExportFilePath = "$env:TEMP\$(Get-Date -Format "yyyy_MM_dd")TeamsWithPrivateChannels.csv" ) # Check or install Microsoft Teams module if ($null -eq (Get-Module -ListAvailable MicrosoftTeams)) { try { Write-Output "Microsoft Teams module not found. Trying to install" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null Install-Module MicrosoftTeams -Force | Out-Null Write-Output "Microsoft Teams module installed" } catch { Write-Output "Unable to install Microsoft Teams module. $($Error[0].Exception.Message)" Return } } # Connect to Microsoft Teams try { Write-Output "Connecting to Microsoft Teams" Connect-MicrosoftTeams | Out-Null } catch { Write-Output "Unable to connect to Microsoft Teams. $($Error[0].Exception.Message)" Return } # Get all teams $AllTeams = Get-Team # Create empty report object $FinalReport = @() # Check channels of each team ForEach ($SingleTeam in $AllTeams) { # Get all private channels try { $AllChannels = $null $AllChannels = Get-TeamChannel -GroupId $SingleTeam.GroupId -MembershipType Private if ($AllChannels) { ForEach ($SingleChannel in $AllChannels) { # Get members of each channel $AllChannelMembers = Get-TeamChannelUser -GroupId $SingleTeam.GroupId -DisplayName $SingleChannel.DisplayName $TeamObject = [PSCustomObject]@{ Team = $SingleTeam.DisplayName ChannelName = $SingleChannel.DisplayName ChannelId = $SingleChannel.Id MembershipType = $SingleChannel.MembershipType Owners = ($AllChannelMembers | Where-Object { $_.Role -eq 'Owner' } | Select-Object -ExpandProperty Name) -join ',' Members = ($AllChannelMembers | Where-Object { $_.Role -eq 'Member' } | Select-Object -ExpandProperty Name) -join ',' } $FinalReport += $TeamObject } } } catch { Write-Output "Failed to get private channels of $($SingleTeam.DisplayName) team. $($Error[0].Exception.Message)" $TeamObject = [PSCustomObject]@{ Team = $SingleTeam.DisplayName Error = "Failed to get channels of the team. $($Error[0].Exception.Message)" } $FinalReport += $TeamObject } } # Print result to the screen Write-Output $FinalReport | Sort-Object User | Format-Table # Export result to CSV file if needed if ($ExportCSV) { $FinalReport | Sort-Object User | Export-Csv -Path $ExportFilePath -NoTypeInformation Write-Output "Report saved to $ExportFilePath" } # Stop before closing powershell window Read-Host "Script completed. Press 'Enter' to finish" Get a list of teams with private channels quickly with Syskit Point But wait, there is a better way to do it! Syskit Point is hands down the easiest way to breeze through discovering teams with private channels. Not only that, but it’s also an impressive platform providing various reports in real-time and allowing easy online access to share with colleagues or managers using a simple link. Its features enable exporting of Excel or PDF reports and performing management actions directly from a report, making it a breeze to check project settings, security, and database information. Additionally, you can review operational policies, time, and task management settings, the projects list, and project permissions. With Syskit Point, you can experience a hassle-free solution for managing and keeping track of your projects. Discover, secure, and control M365 Manage your company’s Microsoft 365 ecosystem with Syskit Point, a scalable platform that will help you govern and secure your environment while giving you deep visibility into your entire inventory. Try for free Related Posts Powershell scripts Find inactive teams in Microsoft 365 with PowerShell Listen up, tech enthusiasts! Are you tired of searching through endless pages o… January 18, 2023 4 min read Powershell scripts Find your shared channels teams with PowerShell script Are you tired of manually tracing all your shared channels teams? Worry no more… January 18, 2023 4 min read