Entra / Microsoft 365 · Teams
Find Teams channels with wiki
Find wiki tabs in Teams channels and report whether wiki configuration content is present.
Connect & set up
Run these once per session. All scopes are read-only unless the script makes changes.
Connect-MgGraph -NoWelcome -Scopes Directory.Read.All, Team.ReadBasic.All, TeamSettings.Read.All, ChannelSettings.Read.All, TeamsTab.Read.All
Run it
The main script. Copy it, or download the .ps1 and run it from your console.
Connect-MgGraph -NoWelcome `-Scopes Directory.Read.All, Team.ReadBasic.All, TeamSettings.Read.All, ChannelSettings.Read.All, TeamsTab.Read.AllWrite-Host "Finding Teams"[array]$Teams = Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All | Sort-Object DisplayNameIf (!($Teams)) {Write-Host "For some reason, I can't find any Teams... exiting..."; break }Clear-Host$Report = [System.Collections.Generic.List[Object]]::new() # Create output file for report$i = 0# Loop through each team to examine its channels, tabs, and appsForEach ($Team in $Teams) {$i++$ProgressBar = "Processing Team " + $Team.DisplayName + " (" + $i + " of " + $Teams.Count + ")"If ($TeamDetails.IsArchived -ne $True) { # Team is not archived, so we can fetch informationWrite-Progress -Activity "Checking Teams Information" -Status $ProgressBar -PercentComplete ($i/$Teams.Count*100)[array]$TeamChannels = Get-MgTeamChannel -TeamId $Team.IdForEach ($Channel in $TeamChannels) {[array]$Tabs = Get-MgTeamChannelTab -ChannelId $Channel.Id -TeamId $Team.Id -ExpandProperty TeamsApp -ErrorAction SilentlyContinueIf ($Tabs) {# Debug line - uncomment it to see the channelid details as they are processed# Write-Host ("Processing tab {0} in channel {1} of team {2}" -f $Tab.DisplayName, $Channel.DisplayName, $Team.DisplayName)ForEach ($Tab in $Tabs) {$WikiContent = $False; $TeamOwners = $nullIf ($Tab.TeamsApp.Id -eq "com.microsoft.teamspace.tab.wiki") {# Check if the wiki configuration says that it has some content[array]$TabData = Get-MgTeamChannelTab -ChannelId $Channel.Id -TeamId $Team.Id -TeamsTabId $Tab.Id -ExpandProperty TeamsApp$WikiContent = $TabData.Configuration.AdditionalProperties['hasContent']} #End if Wiki tabSwitch ($WikiContent) {$True {# Get Team owners[array]$OwnerData = Get-MgGroupOwner -GroupId $Team.Id$TeamOwners = $OwnerData.AdditionalProperties.displayName -Join ", "$WikiCheck = "Wiki content exists"}$False { $WikiCheck = "No content" }Default { $WikiCheck = "No content" }}$ReportLine = [PSCustomObject][Ordered]@{Team = $Team.DisplayNameChannel = $Channel.DisplayName"Tab name" = $Tab.DisplayNameOwners = $TeamOwnersCheck = $WikiCheckTeamId = $Team.IdAppId = $Tab.TeamsApp.Id}$Report.Add($ReportLine) } #End ForEach TabsStart-Sleep -Milliseconds 50 # Brief pause before next channel} #End if Tabs} #End ForEach channel} #End If (archived check)Else { Write-Host "The" $Team.DisplayName "team is archived - no check done" }Start-Sleep -Milliseconds 100} #End ForEach Team$WikiReport = $Report | Where-Object {$_.AppId -eq "com.microsoft.teamspace.tab.wiki" -and $_.Check -eq "Wiki content exists"}$WikiReport | Out-GridView$WikiReport | Export-CSV -NoTypeInformation WikisToReview.CSV -Encoding UTF8 -Delimiter ";"Write-Host ("All done. {0} Teams processed. The Wiki tab with content was found in {1} channels. CSV file generated in WikisToReview.csv" -f $Teams.count, $WikiReport.count)
Attribution
Author
Office365itpros