PowerShell scripts

Find your shared channels teams with PowerShell script

Are you tired of manually tracing all your shared channels teams? Worry no more! Our PowerShell script will do the work for you more efficiently.

In today’s world, Microsoft Teams have proven to be a modern platform for communication and collaboration among teams. However, searching for shared channels teams can be a hassle. That’s why we created a PowerShell script to make it easier!

The challenges with Microsoft Teams shared channels

Shared channels in Microsoft Teams have become critical in fostering collaboration across organizational boundaries, enabling people from different teams or companies to work together seamlessly. They are specially designed for projects that require cross-functional input, allowing for a concentrated space of interaction without full team membership—ideal for involving external partners in specific areas of work while keeping the broader Teams workspace secure and uncompromised.

However, with the convenience of shared channels comes the challenge of managing access and maintaining information security. External users, although necessary for collaboration, introduce complexity in oversight. Additionally, the lifecycle of shared channels must be managed with equal diligence to ensure they remain relevant and secure, a task often beyond the scope of Microsoft’s standard tools and better suited for third-party solutions.

Find shared channels in Teams PowerShell script: details

The script’s purpose is to find all the teams with shared channels, regardless of how many there are. The script scans through all the teams you have and checks for any shared channels among them. The end result will show the team and any shared channels it has. By default, the script outputs the results to the screen, but we also included optional flags for exporting the results to CSV.

Our PowerShell script is a great tool designed for all levels of users, be it a beginner or an advanced level user. All you need to do is copy and paste the script into PowerShell, and voila! Watch as the script does all the hard lifting for you.

Incorporating this script into your team’s workflow can help you save time and boost productivity. Plus, it is crucial for maintaining a well-organized workspace, especially for larger teams. Give it a try, and say goodbye to spending hours searching for channels.

-ExportCSV (if set, this will automatically export the result to a CSV file. If you don’t set an export path, it will export the file to %temp% folder)  

Example: Get-TeamsWithSharedChannels.ps1 -ExportCSV  

-ExportFilePath  Example: Get-TeamsWithSharedChannels.ps1 -ExportCSV -ExportFilePath “C:Tempreport.csv”   

Find your shared channels teams: PowerShell script

# Set script parameters
[CmdletBinding()]
param (
    [switch]$ExportCSV,
    [string]$ExportFilePath = "$env:TEMP\$(Get-Date -Format "yyyy_MM_dd")TeamsWithSharedChannels.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 shared channels
    try {
        $AllChannels = $null
        $AllChannels = Get-TeamChannel -GroupId $SingleTeam.GroupId -MembershipType Shared
        if ($AllChannels) {
            ForEach ($SingleChannel in $AllChannels) {
                $TeamObject = [PSCustomObject]@{
                    Team           = $SingleTeam.DisplayName
                    Channel        = $SingleChannel.DisplayName
                    MembershipType = $SingleChannel.MembershipType
                }
                $FinalReport += $TeamObject
            }
        }
    }
    catch {
        Write-Output "Failed to get shared 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 shared channels quickly with Syskit Point

Discovering teams with shared channels has never been easier. With Syskit Point, Microsoft 365 governance and management platform, you can generate real-time reports and access them with just a click. Sharing reports with your colleagues or manager is now just as easy with a simple online link. It`s the go-to governance and management platform that simplifies your work.

Syskit Point offers an intuitive interface, and lets you schedule reports, export them to Excel or PDF, and even perform management actions directly from a report. You can easily check Project Server sites, security and database information, operational policies, time and task management settings, project lists, and permissions at your convenience.

Go on, boost your productivity and eliminate the hassle of extra work with Syskit Point. Trust us, once you’ve tried it, you’ll never want to go back.

Subscribe to our Newsletter

Related Posts