Home

Microsoft Teams Tenant Wide CSV Report

%3CLINGO-SUB%20id%3D%22lingo-sub-151875%22%20slang%3D%22en-US%22%3EMicrosoft%20Teams%20Tenant%20Wide%20CSV%20Report%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-151875%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EHello%20World%3C%2FSTRONG%3E!%20%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E(10%2F29)%20-%26nbsp%3BI've%20updated%20the%26nbsp%3BTeams%20CSV%20Report%20to%20be%20compliant%20with%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoftTeams%2F0.9.5%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETeams%20PowerShell%200.9.5%3C%2FA%3E.%20Please%20run%20as%20a%20Global%20Admin%2C%20or%20you%20may%20not%20get%20all%20the%20detailed%20information%20below.%20The%20script%20pulls%20all%20of%20the%20following%20information%20for%20all%20Teams%20in%20your%20organization%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETeam%20Name%3C%2FLI%3E%0A%3CLI%3ETeam%20GUID%3C%2FLI%3E%0A%3CLI%3ETeam%20Owners%3C%2FLI%3E%0A%3CLI%3ETeam%20Access%20Type%3C%2FLI%3E%0A%3CLI%3ETeam%20User%20Count%3C%2FLI%3E%0A%3CLI%3ETeam%20SharePoint%20Site%3C%2FLI%3E%0A%3CLI%3ETeam%20Guests%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CDIV%20class%3D%22lia-spoiler-container%22%3E%3CA%20class%3D%22lia-spoiler-link%22%20href%3D%22%23%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ESpoiler%3C%2FA%3E%3CNOSCRIPT%3E(Highlight%20to%20read)%3C%2FNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-border%22%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20%3CEM%3EYou%20must%20be%20signed%20into%20the%20Teams%20PowerShell%20Module%20%26amp%3B%20Exchange%20Online%20PowerShell%20Module%20for%20the%20script%20below%20to%20work.%20Additionally%2C%20it%20can%20take%20a%20while%20to%20run%20if%20you%20have%20many%20Teams%20%26amp%3B%20Groups%20in%20your%20organization!%3C%2FEM%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-container%22%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3ENOTE%3A%20You%20must%20be%20signed%20into%20the%20Teams%20PowerShell%20Module%20%26amp%3B%20Exchange%20Online%20PowerShell%20Module%20for%20the%20script%20below%20to%20work.%20Additionally%2C%20it%20can%20take%20a%20while%20to%20run%20if%20you%20have%20many%20Teams%20%26amp%3B%20Groups%20in%20your%20organization!%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FDIV%3E%0A%3CPRE%3E%23%23%20Created%20by%20SAMCOS%20%40%20MSFT%2C%20Collaboration%20with%20others!%0A%23%23%20You%20must%20first%20connect%20to%20Microsoft%20Teams%20Powershell%20%26amp%3B%20Exchange%20Online%20Powershell%20for%20this%20to%20work.%0A%23%23%20Links%3A%0A%23%23%20Teams%3A%20https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoftTeams%2F0.9.5%0A%23%23%20Exchange%3A%20https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Fexchange-online%2Fconnect-to-exchange-online-powershell%2Fconnect-to-exchange-online-powershell%3Fview%3Dexchange-ps%0A%23%23%20Have%20fun!%20Let%20me%20know%20if%20you%20have%20any%20comments%20or%20asks!%20%0A%0A%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%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%20TeamSite%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%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E-Sam%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-151875%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-250945%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-250945%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20want%20to%20use%20PowerShell%2C%20i%20wrote%20a%20blogpost%20for%20it%20today%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Falexholmeset.blog%2F2018%2F09%2F10%2Ffind-all-teams-teams-using-graph-api-and-powershell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Falexholmeset.blog%2F2018%2F09%2F10%2Ffind-all-teams-teams-using-graph-api-and-powershell%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-234759%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-234759%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20looks%20like%20someone%20figured%20out%20how%20to%20produce%20a%20basic%20list%20using%20MS%20Graph%20API.%20Check%20this%20out%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fsharepoint-specialist.nu%2Fget-all-teams-in-a-tenant-using-microsoft-graph-255f374d5c3a%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsharepoint-specialist.nu%2Fget-all-teams-in-a-tenant-using-microsoft-graph-255f374d5c3a%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-234738%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-234738%22%20slang%3D%22en-US%22%3EGlenn%2C%20this%20also%20does%20not%20appear%20to%20be%20accurate.%20We%20use%20a%20%5BTeam%5D%20suffix%20when%20we%20create%20new%20Teams%20and%20I%20know%20of%20at%20least%2030%20in%20our%20tenant%20but%20this%20script%20only%20captured%20one.%3CBR%20%2F%3E%3CBR%20%2F%3EMIcrosoft%20is%20so%20incredibly%20frustrating%20when%20they%20do%20not%20think%20through%20the%20customer%20experience.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-234602%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-234602%22%20slang%3D%22en-US%22%3E%3CP%3EEDIT%3A%20Doesn't%20seem%20to%20work%20reliably...%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20started%20out%20with%20using%20the%20Exchange%20PowerShell%20module%20Get-UnifiedGroup%2C%20but%20because%20we%20have%20such%20a%20tight%20network%20security%20practice%2C%20it%20was%20hard%20to%20get%20it%20working%20on%20normal%20machines%20behind%20a%20proxy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20write%20a%20similar%20script%20using%20AzureAD%20and%20MicrosoftTeams%20module%20which%20can%20be%20proxied%20because%20it%20uses%20the%20Microsoft%20Graph%20API%20from%20Microsoft%20(HTTP%20Rest)%20instead%20of%20the%20WinRM%20Exchange%20module.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20have%20a%20big%20tenant%2C%20so%20if%20anybody%20can%20test%20performance%2C%20let%20me%20know.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGist%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Fglego%2F5b122deece0c5fcfe464d69eb21ab450%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2Fglego%2F5b122deece0c5fcfe464d69eb21ab450%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%26lt%3B%23%3CBR%20%2F%3E.Synopsis%3CBR%20%2F%3E%20Get%20all%20Microsoft%20Teams%20Groups%3CBR%20%2F%3E.DESCRIPTION%3CBR%20%2F%3E%20This%20script%20will%20check%20any%20existing%20AzureAD%20Group%2C%20if%20there%20are%20any%20Teams%20Users%20%3CBR%20%2F%3E%20attached%20to%20it.%20If%20so%20it%20will%20create%20a%20custom%20object%20and%20mark%20it%20with%20an%20isTeams%20flag.%3CBR%20%2F%3E.EXAMPLE%3CBR%20%2F%3E%20Get-TeamGroup%3CBR%20%2F%3E%23%26gt%3B%3CBR%20%2F%3E%3CBR%20%2F%3EImport-Module%20AzureAD%3CBR%20%2F%3EImport-Module%20MicrosoftTeams%3CBR%20%2F%3E%3CBR%20%2F%3EConnect-AzureAD%3CBR%20%2F%3EConnect-MicrosoftTeams%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20Get%20Potential%20Team%20Groups%3CBR%20%2F%3E%24AzureADGroups%20%3D%20Get-AzureADGroup%20%7C%20Where-Object%20%7B%24_.ObjectType%20-eq%20%22Group%22%20-and%20%24_.MailEnabled%20-eq%20%24true%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%24Teams%3D%40()%3CBR%20%2F%3E%3CBR%20%2F%3Eforeach%20(%24Group%20in%20%24AzureADGroups)%20%7B%3CBR%20%2F%3E%3CBR%20%2F%3E%20%23%20Get%20the%20Object%20Id%20for%20each%20Group%3CBR%20%2F%3E%20%24GroupId%20%3D%20%24Group.ObjectId%3CBR%20%2F%3E%3CBR%20%2F%3E%20%23%20Create%20Team%20HashTable%20to%20Store%20Retrieved%20Information%20%3CBR%20%2F%3E%20%24Team%20%3D%20%5Bordered%5D%40%7B%7D%3CBR%20%2F%3E%20%24Team.Add(%22GroupId%22%2C%20%24GroupId)%3CBR%20%2F%3E%20%24Team.Add(%22DisplayName%22%2C%20%24Group.DisplayName)%3CBR%20%2F%3E%20%24Team.Add(%22Description%22%2C%20%24Group.Description)%3CBR%20%2F%3E%20%24Team.Add(%22Mail%22%2C%20%24Group.Mail)%3CBR%20%2F%3E%20%24Team.Add(%22MailNickname%22%2C%20%24Group.MailNickname)%3CBR%20%2F%3E%3CBR%20%2F%3E%20%23%20Get%20Team%20Users%3CBR%20%2F%3E%20%24TeamUser%20%3D%20Get-TeamUser%20-GroupId%20%24GroupId%3CBR%20%2F%3E%3CBR%20%2F%3E%20if%20(%24TeamUser)%20%7B%3CBR%20%2F%3E%3CBR%20%2F%3E%20%23%20Teams%20Users%20Exists!%3CBR%20%2F%3E%20%24Team.Add(%22isTeams%22%2C%20%24true)%3CBR%20%2F%3E%20%24Team.Add(%22TeamUsers%22%2C%20%24TeamUser)%3CBR%20%2F%3E%3CBR%20%2F%3E%20%7D%20else%20%7B%3CBR%20%2F%3E%20%23%20No%20Teams%20Users...%3CBR%20%2F%3E%20%24Team.Add(%22isTeams%22%2C%20%24false)%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%20%23%20(Optional)%20Add%20the%20Group%20Information%20to%20the%20HashTable%3CBR%20%2F%3E%20%24Team.Add(%22Group%22%2C%20%24Group)%3CBR%20%2F%3E%3CBR%20%2F%3E%20%23%20Dirty%20way%20to%20convert%20the%20HashTable%20into%20a%20PSObject%3CBR%20%2F%3E%20%23%23%20Note%3A%20Somehow%20New-Object%20PSCustomObject%20-Property%20%24Team%20is%20not%20working%20%C2%AF%5C_(%E3%83%84)_%2F%C2%AF%3CBR%20%2F%3E%20%24TeamJSON%20%3D%20ConvertTo-Json%20-InputObject%20%24Team%3CBR%20%2F%3E%20%24TeamObject%20%3D%20%24TeamJSON%20%7C%20ConvertFrom-Json%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Add%20the%20Object%20to%20the%20Teams%20Collection%3CBR%20%2F%3E%20%24Teams%20%2B%3D%20%24TeamObject%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Output%20%24Teams%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-218465%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-218465%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20not%20working%20as%20expected.%20The%20output%20for%20Members%20and%20Owners%20starts%20off%20blank%20then%20repeats%20at%20times%20and%20is%20almost%20completely%20inaccurate.%20The%20Creators%20data%20is%20null%20as%20well.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20the%20CSV%20shows%20the%20first%2017%20groups%20as%20having%20no%20members%20even%20though%20the%20member%20count%20ranges%20from%201-30.%20The%2018th%20group%20appears%20to%20be%20correct%20but%20groups%2019-24%20show%20the%20exact%20same%20member%20list%20as%2018%20even%20though%20they%20are%20completely%20different.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20have%20added%20Import-PSSession%20and%20Connect-MicrosoftTeams%20plus%20modified%20to%20show%20Display%20Name%20instead%20of%20SMTP%20but%20have%20tried%20it%20modified%20and%20unmodified%20with%20the%20same%20results.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20advise.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-173517%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-173517%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EThank%20you%20very%20much%20for%20a%20great%20script.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EI%20found%20one%20thing.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAn%20error%20happens%20when%20%22%24teamschannels%20%3D%20Get-TeamChannel%22%20is%20executed.%20So%20the%20next%20line%20%3C%2FSPAN%3E%3CSPAN%3E%22%24o365GroupMemberList%20%3D%20(Get-UnifiedGroupLinks%3C%2FSPAN%3E%20...%20%22%20might%20not%20be%20executed%20for%20'403'%20and%20'404'%20case.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20thihk%20member%20addresess%20could%20be%20collected%20before%20calling%20Get-TeamChannel%20so%20that%20the%20member%20list%20is%20set%20even%20if%20404%20or%20404%20happens.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EMotoki%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-153684%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-153684%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Sam%2C%3CBR%20%2F%3Ei%20sent%20you%20a%20message%20to%20your%20inbox%20about%20the%20script.%20Just%20a%20couple%20of%20short%20questions%2C%20would%20apreciate%20if%20you%20have%20time%20answering.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eregards%3C%2FP%3E%0A%3CP%3EAlexander%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-152079%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152079%22%20slang%3D%22en-US%22%3EMuch%20appreciated%2C%20thanks%20for%20the%20post.%20Will%20try%20this%20out!!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-151994%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-151994%22%20slang%3D%22en-US%22%3ENice%20one...could%20you%20also%20share%20your%20script%20in%20the%20PowerShell%20Gallery%20so%20others%20can%20download%20it%20from%20there%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-429791%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Enabled%20O365%20Groups%20Report%20PowerShell%20CSV%20Output%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-429791%22%20slang%3D%22en-US%22%3EThis%20looks%20ideal.%3CBR%20%2F%3EAnyway%20to%20produce%20a%20list%20of%20team%20names%2C%20descriptions%2C%20and%20the%20deep%20url%20so%20that%20colleagues%20can%20identify%20interesting%20groups%20and%20ask%20to%20join.%3CBR%20%2F%3ESo%20annoying%20that%20Teams%20does%20not%20have%20this%20capability.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-679103%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Tenant%20Wide%20CSV%20Report%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-679103%22%20slang%3D%22en-US%22%3ECan%20the%20script%20be%20updated%20to%20also%20retrieve%20list%20of%20users%20(UPN)%20in%20all%20the%20teams%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-700203%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%20Tenant%20Wide%20CSV%20Report%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-700203%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F290893%22%20target%3D%22_blank%22%3E%40rkumar0317%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIndeed%20it%20can%2C%20with%20a%20little%20PowerShell%20wrangling...%20Try%20this%20version%2C%20(only%20one%20line%20added%20(line21%20is%20new)%2C%20and%20an%20additional%20entry%20in%20line%2028%2C%20along%20with%20a%20new%20export%20file%20line.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHad%20a%20bit%20of%20fun%20learning%20this%2C%20now%20just%20want%20to%20add%20time%20of%20last%20activity%20to%20each%20Team.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%23%23%20Created%20by%20SAMCOS%20%40%20MSFT%2C%20editted%20by%20%40aowen42%2C%20Collaboration%20with%20others!%3CBR%20%2F%3E%23%23%20You%20must%20first%20connect%20to%20Microsoft%20Teams%20Powershell%20%26amp%3B%20Exchange%20Online%20Powershell%20for%20this%20to%20work.%3CBR%20%2F%3E%23%23%20Links%3A%3CBR%20%2F%3E%23%23%20Teams%3A%20https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoftTeams%2F0.9.5%3CBR%20%2F%3E%23%23%20Exchange%3A%20https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Fexchange-online%2Fconnect-to-exchange-online-powershell%2Fconnect-to-exchange-online-powershell%3Fview%3Dexchange-ps%3CBR%20%2F%3E%23%23%20Have%20fun!%20Let%20me%20know%20if%20you%20have%20any%20comments%20or%20asks!%3CBR%20%2F%3E%3CBR%20%2F%3E%24AllTeamsInOrg%20%3D%20(Get-Team).GroupID%3CBR%20%2F%3E%24TeamList%20%3D%20%40()%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Output%20%22This%20may%20take%20a%20little%20bit%20of%20time...%20Please%20sit%20back%2C%20relax%20and%20enjoy%20some%20GIFs%20inside%20of%20Teams!%22%3CBR%20%2F%3EWrite-Host%20%22%22%3CBR%20%2F%3E%3CBR%20%2F%3EForeach%20(%24Team%20in%20%24AllTeamsInOrg)%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%24TeamGUID%20%3D%20%24Team.ToString()%3CBR%20%2F%3E%24TeamGroup%20%3D%20Get-UnifiedGroup%20-identity%20%24Team.ToString()%3CBR%20%2F%3E%23%24TeamMembers%20%3D%20(Get-UnifiedGroupLinks%20-Identity%20%22%24identity%22%20-LinkType%20Members%20%7C%20Select-Object%20PrimarySMTPAddress)%3CBR%20%2F%3E%24TeamName%20%3D%20(Get-Team%20%7C%20%3F%7B%24_.GroupID%20-eq%20%24Team%7D).DisplayName%3CBR%20%2F%3E%24TeamOwner%20%3D%20(Get-TeamUser%20-GroupId%20%24Team%20%7C%20%3F%7B%24_.Role%20-eq%20'Owner'%7D).User%3CBR%20%2F%3E%24TeamMember%20%3D%20(Get-TeamUser%20-GroupId%20%24Team%20%7C%20%3F%7B%24_.Role%20-eq%20'Member'%7D).User%3CBR%20%2F%3E%24TeamUserCount%20%3D%20((Get-TeamUser%20-GroupId%20%24Team).UserID).Count%3CBR%20%2F%3E%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%3CBR%20%2F%3Eif%20(%24TeamGuest%20-eq%20%24null)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24TeamGuest%20%3D%20%22No%20Guests%20in%20Team%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%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%20TeamMembers%20%3D%20%24TeamMember%20-join%20'%2C%20'%3B%20TeamMemberCount%20%3D%20%24TeamUserCount%3B%20TeamSite%20%3D%20%24TeamGroup.SharePointSiteURL%3B%20AccessType%20%3D%20%24TeamGroup.AccessType%3B%20TeamGuests%20%3D%20%24TeamGuest%20-join%20'%2C'%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%23%23%23%23%23%23%23%3CBR%20%2F%3E%3CBR%20%2F%3E%24TestPath%20%3D%20test-path%20-path%20'c%3A%5Ctemp'%3CBR%20%2F%3Eif%20(%24TestPath%20-ne%20%24true)%20%7BNew-Item%20-ItemType%20directory%20-Path%20'c%3A%5Ctemp'%20%7C%20Out-Null%3CBR%20%2F%3Ewrite-Host%20'Creating%20directory%20to%20write%20file%20to%20c%3A%5Ctemp.%20Your%20file%20is%20uploaded%20as%20TeamsDatav4.csv'%7D%3CBR%20%2F%3Eelse%20%7BWrite-Host%20%22Your%20file%20has%20been%20uploaded%20to%20c%3A%5Ctemp%20as%20'TeamsDatav4.csv'%22%7D%3CBR%20%2F%3E%24TeamList%20%7C%20export-csv%20c%3A%5Ctemp%5CTeamsDatav4.csv%20-NoTypeInformation%3C%2FPRE%3E%3CHR%20%2F%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Sam Cosby
Microsoft

Hello World!  (10/29) - I've updated the Teams CSV Report to be compliant with Teams PowerShell 0.9.5. Please run as a Global Admin, or you may not get all the detailed information below. The script pulls all of the following information for all Teams in your organization:

 

  • Team Name
  • Team GUID
  • Team Owners
  • Team Access Type
  • Team User Count
  • Team SharePoint Site
  • Team Guests
Spoiler
NOTE: You must be signed into the Teams PowerShell Module & Exchange Online PowerShell Module for the script below to work. Additionally, it can take a while to run if you have many Teams & Groups in your organization!
## Created by SAMCOS @ MSFT, Collaboration with others!
## You must first connect to Microsoft Teams Powershell & Exchange Online Powershell for this to work.
## Links:
## Teams: https://www.powershellgallery.com/packages/MicrosoftTeams/0.9.5
## Exchange: https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
## Have fun! Let me know if you have any comments or asks! 

$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"
            }
        $TeamList = $TeamList + [PSCustomObject]@{TeamName = $TeamName; TeamObjectID = $TeamGUID; TeamOwners = $TeamOwner -join ', '; TeamMemberCount = $TeamUserCount; TeamSite = $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

 

-Sam

12 Replies
Nice one...could you also share your script in the PowerShell Gallery so others can download it from there?
Much appreciated, thanks for the post. Will try this out!!

Hi Sam,
i sent you a message to your inbox about the script. Just a couple of short questions, would apreciate if you have time answering.

 

regards

Alexander

Thank you very much for a great script.

 

I found one thing.

An error happens when "$teamschannels = Get-TeamChannel" is executed. So the next line "$o365GroupMemberList = (Get-UnifiedGroupLinks ... " might not be executed for '403' and '404' case. 

I thihk member addresess could be collected before calling Get-TeamChannel so that the member list is set even if 404 or 404 happens.

 

Thanks,

Motoki

This is not working as expected. The output for Members and Owners starts off blank then repeats at times and is almost completely inaccurate. The Creators data is null as well. 

 

For example, the CSV shows the first 17 groups as having no members even though the member count ranges from 1-30. The 18th group appears to be correct but groups 19-24 show the exact same member list as 18 even though they are completely different.


I have added Import-PSSession and Connect-MicrosoftTeams plus modified to show Display Name instead of SMTP but have tried it modified and unmodified with the same results. 

 

Please advise. 

EDIT: Doesn't seem to work reliably... 

 

I started out with using the Exchange PowerShell module Get-UnifiedGroup, but because we have such a tight network security practice, it was hard to get it working on normal machines behind a proxy.

 

So I write a similar script using AzureAD and MicrosoftTeams module which can be proxied because it uses the Microsoft Graph API from Microsoft (HTTP Rest) instead of the WinRM Exchange module.

 

I don't have a big tenant, so if anybody can test performance, let me know.

 

Gist: https://gist.github.com/glego/5b122deece0c5fcfe464d69eb21ab450

 

<#
.Synopsis
Get all Microsoft Teams Groups
.DESCRIPTION
This script will check any existing AzureAD Group, if there are any Teams Users
attached to it. If so it will create a custom object and mark it with an isTeams flag.
.EXAMPLE
Get-TeamGroup
#>

Import-Module AzureAD
Import-Module MicrosoftTeams

Connect-AzureAD
Connect-MicrosoftTeams

# Get Potential Team Groups
$AzureADGroups = Get-AzureADGroup | Where-Object {$_.ObjectType -eq "Group" -and $_.MailEnabled -eq $true}

$Teams=@()

foreach ($Group in $AzureADGroups) {

# Get the Object Id for each Group
$GroupId = $Group.ObjectId

# Create Team HashTable to Store Retrieved Information
$Team = [ordered]@{}
$Team.Add("GroupId", $GroupId)
$Team.Add("DisplayName", $Group.DisplayName)
$Team.Add("Description", $Group.Description)
$Team.Add("Mail", $Group.Mail)
$Team.Add("MailNickname", $Group.MailNickname)

# Get Team Users
$TeamUser = Get-TeamUser -GroupId $GroupId

if ($TeamUser) {

# Teams Users Exists!
$Team.Add("isTeams", $true)
$Team.Add("TeamUsers", $TeamUser)

} else {
# No Teams Users...
$Team.Add("isTeams", $false)
}

# (Optional) Add the Group Information to the HashTable
$Team.Add("Group", $Group)

# Dirty way to convert the HashTable into a PSObject
## Note: Somehow New-Object PSCustomObject -Property $Team is not working ¯\_(ツ)_/¯
$TeamJSON = ConvertTo-Json -InputObject $Team
$TeamObject = $TeamJSON | ConvertFrom-Json

# Add the Object to the Teams Collection
$Teams += $TeamObject
}

Write-Output $Teams

 

Glenn, this also does not appear to be accurate. We use a [Team] suffix when we create new Teams and I know of at least 30 in our tenant but this script only captured one.

MIcrosoft is so incredibly frustrating when they do not think through the customer experience.

It looks like someone figured out how to produce a basic list using MS Graph API. Check this out:

 

https://sharepoint-specialist.nu/get-all-teams-in-a-tenant-using-microsoft-graph-255f374d5c3a

This looks ideal.
Anyway to produce a list of team names, descriptions, and the deep url so that colleagues can identify interesting groups and ask to join.
So annoying that Teams does not have this capability.

Can the script be updated to also retrieve list of users (UPN) in all the teams?

@rkumar0317 

 

Indeed it can, with a little PowerShell wrangling... Try this version, (only one line added (line21 is new), and an additional entry in line 28, along with a new export file line.

 

Had a bit of fun learning this, now just want to add time of last activity to each Team.

 

## Created by SAMCOS @ MSFT, editted by @aowen42, Collaboration with others!
## You must first connect to Microsoft Teams Powershell & Exchange Online Powershell for this to work.
## Links:
## Teams: https://www.powershellgallery.com/packages/MicrosoftTeams/0.9.5
## Exchange: https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
## Have fun! Let me know if you have any comments or asks!

$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()
#$TeamMembers = (Get-UnifiedGroupLinks -Identity "$identity" -LinkType Members | Select-Object PrimarySMTPAddress)
$TeamName = (Get-Team | ?{$_.GroupID -eq $Team}).DisplayName
$TeamOwner = (Get-TeamUser -GroupId $Team | ?{$_.Role -eq 'Owner'}).User
$TeamMember = (Get-TeamUser -GroupId $Team | ?{$_.Role -eq 'Member'}).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"
}
$TeamList = $TeamList + [PSCustomObject]@{TeamName = $TeamName; TeamObjectID = $TeamGUID; TeamOwners = $TeamOwner -join ', '; TeamMembers = $TeamMember -join ', '; TeamMemberCount = $TeamUserCount; TeamSite = $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 TeamsDatav4.csv'}
else {Write-Host "Your file has been uploaded to c:\temp as 'TeamsDatav4.csv'"}
$TeamList | export-csv c:\temp\TeamsDatav4.csv -NoTypeInformation

 

Related Conversations
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
50 Replies
Teams Crashes on Startup
Slarti in Microsoft Teams on
45 Replies
Teams Calling - Dial pad missing
Chris Cooper in Microsoft Teams on
61 Replies
Teams for Mac Client
tlindgren in Microsoft Teams on
5 Replies