SOLVED

Get all Teams and channel information using PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-1312145%22%20slang%3D%22en-US%22%3EGet%20all%20Teams%20and%20channel%20information%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1312145%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20export%20a%20list%20of%20all%20teams%20in%20our%20environment%20along%20with%20their%20associated%20channels%20to%20CSV.%26nbsp%3B%20I%20have%20used%20the%20script%20below%20previously%20(although%20this%20was%20around%20a%20year%20ago)%20but%20am%20now%20getting%20an%20error%20saying%20that%26nbsp%3BConnect-PnPGraph%20is%20not%20recognised.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20not%20sure%20what's%20changed%20and%20I%20can't%20seem%20to%20find%20any%20documentation%20on%20how%20I%20can%20resolve%20this%20issue%3F%26nbsp%3B%20I've%20updated%20my%20PnP%20PowerShell%20cmdlets%20but%20the%20issue%20still%20occurs.%26nbsp%3B%20The%20script%20I'm%20using%20is%20below%20and%20I'd%20really%20appreciate%20any%20help%20anyone%20can%20give.%26nbsp%3B%20Alternatively%2C%20if%20there%20is%20another%20way%20I%20can%20get%20this%20information%20exported%20I'd%20be%20really%20interested.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Efunction%20Export-TeamsList%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Eparam%20(%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24ExportPath%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E)%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Eprocess%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EConnect-PnPMicrosoftGraph%20-Scopes%20%22Group.Read.All%22%2C%22User.ReadBasic.All%22%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24accesstoken%20%3DGet-PnPAccessToken%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24group%20%3D%20Invoke-RestMethod%20-Headers%20%40%7BAuthorization%20%3D%20%22Bearer%20%24accesstoken%22%7D%20-Uri%20%22%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%3F%60%24filter%3DgroupTypes%2Fany(c%3Ac%2Beq%2B%60'Unified%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%3F%60%24filter%3DgroupTypes%2Fany(c%3Ac%2Beq%2B%60'Unified%3C%2FA%3E%60')%22%20-Method%20Get%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24TeamsList%20%3D%20%40()%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Edo%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Eforeach(%24value%20in%20%24group.value)%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%22Group%20Name%3A%20%22%20%2B%20%24value.displayName%20%2B%20%22%20Group%20Type%3A%20%22%20%2B%20%24value.groupTypes%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Eif(%24value.groupTypes%20-eq%20%22Unified%22)%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24id%3D%20%24value.id%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3ETry%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24team%20%3D%20Invoke-RestMethod%20-Headers%20%40%7BAuthorization%20%3D%20%22Bearer%20%24accesstoken%22%7D%20-Uri%20%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FGroups%2F%24id%2Fchannels%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FGroups%2F%24id%2Fchannels%3C%2FA%3E%20-Method%20Get%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%22Channel%20count%20for%20%22%20%2B%20%24value.displayName%20%2B%20%22%20is%20%22%20%2B%20%24team.value.id.count%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3ECatch%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%22Could%20not%20get%20channels%20for%20%22%20%2B%20%24value.displayName%20%2B%20%22.%20%22%20%2B%20%24_.Exception.Message%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24team%20%3D%20%24null%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EIf(%24team.value.id.count%20-ge%201)%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Owner%20%3D%20Invoke-RestMethod%20-Headers%20%40%7BAuthorization%20%3D%20%22Bearer%20%24accesstoken%22%7D%20-Uri%20%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2FGroups%2F%24id%2Fowners%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2FGroups%2F%24id%2Fowners%3C%2FA%3E%20-Method%20Get%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams%20%3D%20%22%22%20%7C%20Select%20%22TeamsName%22%2C%22TeamType%22%2C%22Channelcount%22%2C%22ChannelName%22%2C%22Owners%22%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams.TeamsName%20%3D%20%24value.displayname%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams.TeamType%20%3D%20%24value.visibility%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams.ChannelCount%20%3D%20%24team.value.id.count%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams.ChannelName%20%3D%20%24team.value.displayName%20-join%20%22%3B%22%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams.Owners%20%3D%20%24Owner.value.userPrincipalName%20-join%20%22%3B%22%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24TeamsList%2B%3D%20%24Teams%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24Teams%3D%24null%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Eif%20(%24group.'%40odata.nextLink'%20-eq%20%24null%20)%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Ebreak%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Eelse%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24group%20%3D%20Invoke-RestMethod%20-Headers%20%40%7BAuthorization%20%3D%20%22Bearer%20%24accesstoken%22%7D%20-Uri%20%24group.'%40odata.nextLink'%20-Method%20Get%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7Dwhile(%24true)%3B%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24TeamsList%20%7CExport-csv%20%24ExportPath%20-NoTypeInformation%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EExport-TeamsList%20-ExportPath%20%22C%3A%5Cteamslist.csv%22%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1312145%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1312701%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20Teams%20and%20channel%20information%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1312701%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F358881%22%20target%3D%22_blank%22%3E%40gcjuw84%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20link%20of%20commands%20for%20your%20reference.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExport%20all%20the%20Teams%20Channel%20in%20Office%20365%20Tenant%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FExport-Teams-Channel-de703ad0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FExport-Teams-Channel-de703ad0%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-teams%2Fmicrosoft-teams-tenant-wide-csv-report%2Fm-p%2F151875%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-teams%2Fmicrosoft-teams-tenant-wide-csv-report%2Fm-p%2F151875%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20Regards%2C%3C%2FP%3E%3CP%3ESatish%20U%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1330293%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20Teams%20and%20channel%20information%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1330293%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F259632%22%20target%3D%22_blank%22%3E%40Satish2805%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat's%20great%20thanks.%26nbsp%3B%20I%20used%20the%20script%20provided%20in%20your%20second%20link%20and%20added%20a%20few%20lines%20to%20also%20output%20a%20count%20of%20the%20channels%20in%20each%20team%20along%20with%20the%20channel%20names.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again%20for%20your%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1401709%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20Teams%20and%20channel%20information%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1401709%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F358881%22%20target%3D%22_blank%22%3E%40gcjuw84%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20post%20the%20final%20script.%3CBR%20%2F%3EI%20am%20having%20trouble%20with%20exporting%20the%20channels%20with%20this%20script.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1402422%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20Teams%20and%20channel%20information%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1402422%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F161161%22%20target%3D%22_blank%22%3E%40Sebastian%20Di%20Cecca%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENo%20problem%2C%20the%20final%20script%20is%20below.%26nbsp%3B%20Before%20running%20the%20script%20you%20need%20to%20make%20sure%20you%20run%20Connect-MicrosoftTeams%20and%20Connect-ExchangeOnline.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20problems%20let%20me%20know.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24AllTeamsInOrg%20%3D%20(Get-Team).GroupID%0A%24TeamList%20%3D%20%40()%0A%0AWrite-Output%20%22This%20may%20take%20a%20little%20bit%20of%20time...%20Please%20sit%20back%2C%20relax%20and%20enjoy%20some%20GIFs%20inside%20of%20Teams!%22%0AWrite-Host%20%22%22%0A%0AForeach%20(%24Team%20in%20%24AllTeamsInOrg)%0A%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%24TeamGUID%20%3D%20%24Team.ToString()%0A%20%20%20%20%20%20%20%20%24TeamGroup%20%3D%20Get-UnifiedGroup%20-identity%20%24Team.ToString()%0A%20%20%20%20%20%20%20%20%24TeamName%20%3D%20(Get-Team%20%7C%20%3F%7B%24_.GroupID%20-eq%20%24Team%7D).DisplayName%0A%20%20%20%20%20%20%20%20%24TeamOwner%20%3D%20(Get-TeamUser%20-GroupId%20%24Team%20%7C%20%3F%7B%24_.Role%20-eq%20'Owner'%7D).User%0A%20%20%20%20%20%20%20%20%24TeamUserCount%20%3D%20((Get-TeamUser%20-GroupId%20%24Team).UserID).Count%0A%20%20%20%20%20%20%20%20%24TeamGuest%20%3D%20(Get-UnifiedGroupLinks%20-LinkType%20Members%20-identity%20%24Team%20%7C%20%3F%7B%24_.Name%20-match%20%22%23EXT%23%22%7D).Name%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(%24TeamGuest%20-eq%20%24null)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24TeamGuest%20%3D%20%22No%20Guests%20in%20Team%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%24TeamChannels%20%3D%20(Get-TeamChannel%20-GroupId%20%24Team).DisplayName%0A%20%24ChannelCount%20%3D%20(Get-TeamChannel%20-GroupId%20%24Team).ID.Count%0A%20%20%20%20%20%20%20%20%24TeamList%20%3D%20%24TeamList%20%2B%20%5BPSCustomObject%5D%40%7BTeamName%20%3D%20%24TeamName%3B%20TeamObjectID%20%3D%20%24TeamGUID%3B%20TeamOwners%20%3D%20%24TeamOwner%20-join%20'%2C%20'%3B%20TeamMemberCount%20%3D%20%24TeamUserCount%3B%20NoOfChannels%20%3D%20%24ChannelCount%3B%20ChannelNames%20%3D%20%24TeamChannels%20-join%20'%2C%20'%3B%20SharePointSite%20%3D%20%24TeamGroup.SharePointSiteURL%3B%20AccessType%20%3D%20%24TeamGroup.AccessType%3B%20TeamGuests%20%3D%20%24TeamGuest%20-join%20'%2C'%7D%0A%7D%0A%0A%23%23%23%23%23%23%23%0A%0A%24TestPath%20%3D%20test-path%20-path%20'c%3A%5Ctemp'%0Aif%20(%24TestPath%20-ne%20%24true)%20%7BNew-Item%20-ItemType%20directory%20-Path%20'c%3A%5Ctemp'%20%7C%20Out-Null%0A%20%20%20%20write-Host%20%20'Creating%20directory%20to%20write%20file%20to%20c%3A%5Ctemp.%20Your%20file%20is%20uploaded%20as%20TeamsDatav2.csv'%7D%0Aelse%20%7BWrite-Host%20%22Your%20file%20has%20been%20uploaded%20to%20c%3A%5Ctemp%20as%20'TeamsDatav2.csv'%22%7D%0A%24TeamList%20%7C%20export-csv%20c%3A%5Ctemp%5CTeamsDatav2.csv%20-NoTypeInformation%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1402598%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20Teams%20and%20channel%20information%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1402598%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F358881%22%20target%3D%22_blank%22%3E%40gcjuw84%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20alot!%20I'll%20give%20it%20a%20try!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi everyone

 

I'm trying to export a list of all teams in our environment along with their associated channels to CSV.  I have used the script below previously (although this was around a year ago) but am now getting an error saying that Connect-PnPGraph is not recognised.

 

I'm not sure what's changed and I can't seem to find any documentation on how I can resolve this issue?  I've updated my PnP PowerShell cmdlets but the issue still occurs.  The script I'm using is below and I'd really appreciate any help anyone can give.  Alternatively, if there is another way I can get this information exported I'd be really interested.

 

Thanks in advance.

 

function Export-TeamsList
{
param (
$ExportPath
)
process{
Connect-PnPMicrosoftGraph -Scopes "Group.Read.All","User.ReadBasic.All"
$accesstoken =Get-PnPAccessToken
$group = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri "https://graph.microsoft.com/v1.0/groups?`$filter=groupTypes/any(c:c+eq+`'Unified`')" -Method Get
$TeamsList = @()
do
{
foreach($value in $group.value)
{
"Group Name: " + $value.displayName + " Group Type: " + $value.groupTypes
if($value.groupTypes -eq "Unified")
{
$id= $value.id
Try
{
$team = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/beta/Groups/$id/channels -Method Get
"Channel count for " + $value.displayName + " is " + $team.value.id.count
}
Catch
{
"Could not get channels for " + $value.displayName + ". " + $_.Exception.Message
$team = $null
}
If($team.value.id.count -ge 1)
{
$Owner = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/v1.0/Groups/$id/owners -Method Get
$Teams = "" | Select "TeamsName","TeamType","Channelcount","ChannelName","Owners"
$Teams.TeamsName = $value.displayname
$Teams.TeamType = $value.visibility
$Teams.ChannelCount = $team.value.id.count
$Teams.ChannelName = $team.value.displayName -join ";"
$Teams.Owners = $Owner.value.userPrincipalName -join ";"
$TeamsList+= $Teams
$Teams=$null
}
}
}
if ($group.'@odata.nextLink' -eq $null )
{
break
}
else
{
$group = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri $group.'@odata.nextLink' -Method Get
}
}while($true);
$TeamsList |Export-csv $ExportPath -NoTypeInformation
}
}
Export-TeamsList -ExportPath "C:\teamslist.csv"

8 Replies
Best Response confirmed by gcjuw84 (Contributor)
Solution

Hi @gcjuw84 

 

Here is the link of commands for your reference.

 

Export all the Teams Channel in Office 365 Tenant

https://gallery.technet.microsoft.com/office/Export-Teams-Channel-de703ad0

https://techcommunity.microsoft.com/t5/microsoft-teams/microsoft-teams-tenant-wide-csv-report/m-p/15...

 

With Regards,

Satish U

@Satish2805 

 

That's great thanks.  I used the script provided in your second link and added a few lines to also output a count of the channels in each team along with the channel names.

 

Thanks again for your help.

@gcjuw84 

 

Can you post the final script.
I am having trouble with exporting the channels with this script.

@Sebastian Di Cecca 

 

No problem, the final script is below.  Before running the script you need to make sure you run Connect-MicrosoftTeams and Connect-ExchangeOnline.

 

Any problems let me know.

 

$AllTeamsInOrg = (Get-Team).GroupID
$TeamList = @()

Write-Output "This may take a little bit of time... Please sit back, relax and enjoy some GIFs inside of Teams!"
Write-Host ""

Foreach ($Team in $AllTeamsInOrg)
{       
        $TeamGUID = $Team.ToString()
        $TeamGroup = Get-UnifiedGroup -identity $Team.ToString()
        $TeamName = (Get-Team | ?{$_.GroupID -eq $Team}).DisplayName
        $TeamOwner = (Get-TeamUser -GroupId $Team | ?{$_.Role -eq 'Owner'}).User
        $TeamUserCount = ((Get-TeamUser -GroupId $Team).UserID).Count
        $TeamGuest = (Get-UnifiedGroupLinks -LinkType Members -identity $Team | ?{$_.Name -match "#EXT#"}).Name
            if ($TeamGuest -eq $null)
            {
                $TeamGuest = "No Guests in Team"
            }
        $TeamChannels = (Get-TeamChannel -GroupId $Team).DisplayName
	$ChannelCount = (Get-TeamChannel -GroupId $Team).ID.Count
        $TeamList = $TeamList + [PSCustomObject]@{TeamName = $TeamName; TeamObjectID = $TeamGUID; TeamOwners = $TeamOwner -join ', '; TeamMemberCount = $TeamUserCount; NoOfChannels = $ChannelCount; ChannelNames = $TeamChannels -join ', '; SharePointSite = $TeamGroup.SharePointSiteURL; AccessType = $TeamGroup.AccessType; TeamGuests = $TeamGuest -join ','}
}

#######

$TestPath = test-path -path 'c:\temp'
if ($TestPath -ne $true) {New-Item -ItemType directory -Path 'c:\temp' | Out-Null
    write-Host  'Creating directory to write file to c:\temp. Your file is uploaded as TeamsDatav2.csv'}
else {Write-Host "Your file has been uploaded to c:\temp as 'TeamsDatav2.csv'"}
$TeamList | export-csv c:\temp\TeamsDatav2.csv -NoTypeInformation

@gcjuw84 

Thanks alot! I'll give it a try!

@gcjuw84 

I have used the scrip and it is great!

But I see that it only lists the public channels.

Some way you list the public and private?

thanks

@amkaccion1966 

I've just tested this my end and the script seems to show both public and private channels.  The Get-TeamChannel should show all channels regardless of whether they're public or private and this is what's used in the script.

 

If you go into the Teams Admin Centre and view team details via the Manage Teams can you see private channels for a team that has them there?

Is there a place where I can grab dates of "last's", i.i. Last chat message, last user added, last file added, etc.  Our organization implemented Teams with no oversight so there are a lot of orphaned teams.
Thanks!
@gcjuw84