Home

Teams-enabled O365 Groups report workaround in PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-141029%22%20slang%3D%22en-US%22%3ETeams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141029%22%20slang%3D%22en-US%22%3E%3CP%3EOverdue%20Edit%3A%20As%20of%20version%200.9.6%20of%20the%20%3CA%20title%3D%22MicrosoftTeams%20PowerShell%20module%22%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoftTeams%2F0.9.6%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoftTeams%20PowerShell%20module%3C%2FA%3E%2C%20the%20Get-Team%20command%20now%20returns%20all%20teams%20when%20run%20as%20an%20administrator.%20%3CA%20title%3D%22List%20all%20teams%20in%20Microsoft%20Teams%20for%20an%20organization%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fteams-list-all-teams%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGraph%20API%20calls%3C%2FA%3E%20can%20also%20do%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E--%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20current%20(0.9.1)%20beta%20version%20of%20the%20Teams%20PowerShell%20module%2C%20as%20has%20been%20pointed%20out%20in%20other%20posts%2C%20the%20Get-Team%20command%20only%20returns%20Teams%20you%20--%20the%20user%20running%20the%20command%20--%20are%20a%20member%20of.%20However%2C%20as%20community%20member%20Nino%20Paulo%20found%20in%20%3CA%20title%3D%22How%20to%20get%20the%20list%20of%20Microsoft%20Team%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams%2FHow-to-get-the-list-of-Microsoft-Team%2Fm-p%2F134657%22%20target%3D%22_blank%22%3Eanother%20thread%3C%2FA%3E%20specific%20to%20the%20Graph%20API%20endpoint%2C%20we%20can%20use%20the%20error%20codes%20we%20get%20back%20from%20some%20of%20the%20related%20Teams%20commands%20to%20work%20around%20the%20current%20limitation.%20This%20can%20work%20for%20PowerShell%20as%20well%2C%20which%20may%20fit%20better%20into%20existing%20workflows%20and%20admin%20experience.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFollowing%20is%20a%20snippet%20that%20uses%20the%20Get-UnifiedGroup%20Exchange%20Online%20PS%20command%20to%20get%20all%20O365%20Groups%2C%20then%20uses%20the%20Get-TeamChannel%20Microsoft%20Teams%20PS%20command%20across%20them%20and%20based%20on%20the%20response%20(no%20error%2C%20a%20403%20Access%20Denied%20error%2C%20or%20a%20404%20Not%20Found%20error)%20reports%20whether%20the%20O365%20Group%20is%20TeamsEnabled.%20This%20can%20stand%20as%20its%20own%20.ps1%2C%20can%20fit%20into%20another%20script%2C%20or%20the%20output%20can%20be%20modified%20as%20needed%20(for%20example%2C%20output%20Primary%20SMTP%20rather%20than%20Azure%20AD%20Group%20ID).%20Note%20as%20written%20it%20does%20need%20to%20have%20an%20Exchange%20Online%20PS%20session%20and%20Microsoft%20Teams%20PS%20session%20already%20connected%20to%20work.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24o365groups%20%3D%20Get-UnifiedGroup%0Aforeach%20(%24o365group%20in%20%24o365groups)%20%7B%0A%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20%24teamschannels%20%3D%20Get-TeamChannel%20-GroupId%20%24o365group.ExternalDirectoryObjectId%0A%20%20%20%20%20%20%20%20%5Bpscustomobject%5D%40%7BGroupId%20%3D%20%24o365group.ExternalDirectoryObjectId%3B%20GroupName%20%3D%20%24o365group.DisplayName%3B%20TeamsEnabled%20%3D%20%24true%7D%0A%20%20%20%20%7D%20catch%20%7B%0A%20%20%20%20%20%20%20%20%24ErrorCode%20%3D%20%24_.Exception.ErrorCode%0A%20%20%20%20%20%20%20%20switch%20(%24ErrorCode)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22404%22%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bpscustomobject%5D%40%7BGroupId%20%3D%20%24o365group.ExternalDirectoryObjectId%3B%20GroupName%20%3D%20%24o365group.DisplayName%3B%20TeamsEnabled%20%3D%20%24false%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%22403%22%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bpscustomobject%5D%40%7BGroupId%20%3D%20%24o365group.ExternalDirectoryObjectId%3B%20GroupName%20%3D%20%24o365group.DisplayName%3B%20TeamsEnabled%20%3D%20%24true%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20default%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Error%20(%22Unknown%20ErrorCode%20trying%20to%20'Get-TeamChannel%20-GroupId%20%7B0%7D'%20%3A%3A%20%7B1%7D%22%20-f%20%24o365group%2C%20%24ErrorCode)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%3C%2FPRE%3E%0A%3CP%3ESample%20output%20from%20the%20snippet%3A%3C%2FP%3E%0A%3CPRE%3EGroupId%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20GroupName%20%20%20%20TeamsEnabled%0A-------%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20---------%20%20%20%20------------%0A399cd314-1c6d-4c8d-ad03-54a0ac07cc93%20Test%20Group%201%20%20%20%20%20%20%20%20False%0A6a175eba-02d9-44a7-b49e-ac71d7aeeaf7%20Test%20Team%20%20%20%20%20%20%20%20%20%20%20%20True%3C%2FPRE%3E%0A%3CP%3EAs%20with%20any%20example%20code%2C%20please%20test%20prior%20to%20production%20use.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-141029%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdministrator%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETips%20%26amp%3B%20Tricks%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-259815%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-259815%22%20slang%3D%22en-US%22%3E%3CP%3Eje%20suis%20content%20d'etre%20a%20Paris%20pour%20mwc%20'18%20aussi%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-259813%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-259813%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EBy%20the%20way%20very%20happy%20to%20see%20you%20coming%20in%20France%20next%20month%20for%20MWC'18%20and%20your%20session%20%3A%26nbsp%3BWill%20Teams%20Take%20Over%20from%20Email%20%3F!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-259805%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-259805%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20Team%20Chat%20folder%20might%20be%20present%20even%20if%20a%20group%20is%20not%20team%20enabled.%20I%20think%20groups%20created%20through%20OWA%20might%20provision%20the%20folder.%20In%20any%20case%2C%20it%20is%20best%20to%20check%20to%20see%20if%20compliance%20items%20are%20present.%20If%20the%20count%20is%200%2C%20then%20the%20team%20has%20never%20been%20used%20or%20the%20group%20is%20not%20team-enabled.%20A%20count%20%26gt%3B%201%20means%20that%20someone%20has%20accessed%20the%20group%20and%20sent%20some%20messages.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-259802%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-259802%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20you%20guidance%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20understand%20what%20is%20%22Team%20Chat%22%20folder%20in%20the%20group%20mailbox%20with%20an%20other%20great%20article%20from%20you%20as%20allways%20...%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.petri.com%2Fteams-compliance-story%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.petri.com%2Fteams-compliance-story%3C%2FA%3E%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20understand%20the%20logic%20%22because%20that%20will%20tell%20me%20that%20the%20team%20is%20used%22%20but%2C%20is%20this%20%22Team%20Chat%22%20folder%20also%20present%20by%20default%20%3F%20(for%20exemple%20%3A%20when%20we%20look%20at%20an%20%22inactive%22%20Teams-enabled%20O365%20Groups)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-259746%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-259746%22%20slang%3D%22en-US%22%3E%3CP%3E1.%20You%20do%20need%20to%20connect%20to%20the%20Teams%20endpoint%20to%20use%20the%20Teams%20cmdlets%20(Get-Team%20etc.)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20I%20don't%20recommend%20checking%20for%20channels%20any%20longer.%20It%20is%20more%20effective%20to%20look%20for%20the%20presence%20of%20the%20Team%20Chat%20folder%20in%20the%20group%20mailbox%20and%20see%20if%20any%20compliance%20items%20are%20in%20it%20because%20that%20will%20tell%20you%20that%20the%20team%20is%20used.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-259736%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-259736%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%3A%20many%20thanks%20for%20this%20script%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22%24%22%20missed%20for%20%22TeamsEnabled%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Edefault%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Error%20(%22Unknown%20ErrorCode%20trying%20to%20'Get-TeamChannel%20-GroupId%20%7B0%7D'%20%3A%3A%20%7B1%7D%22%20-f%20%24G%2C%20%24ErrorCode)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20TeamEnabled%20%3D%20%24False%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%26nbsp%3Bit%20seems%20also%20know%2C%20we%20need%20to%20use%20this%20cmdlet%20to%20be%20able%20to%20use%26nbsp%3B%3CSPAN%3EMicrosoft%20Teams%20cmdlet%20requests%3C%2FSPAN%3E%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EConnect-MicrosoftTeams%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fteams%2Fconnect-microsoftteams%3Fview%3Dteams-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fteams%2Fconnect-microsoftteams%3Fview%3Dteams-ps%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eanyone%20faced%20this%20change%20too%20%3F%20%3A)%3C%2Fimg%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20feedback%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141242%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141242%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Dave%2C%20using%20Get-TeamChannel%20is%20an%20interesting%20way%20to%20figure%20out%20whether%20a%20group%20is%20team-enabled.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20of%20the%20wonders%20of%20PowerShell%20is%20how%20easy%20it%20is%20to%20take%20different%20bits%20of%20code%20and%20stitch%20them%20together.%20I%20took%20your%20code%20and%20some%20code%20I%20had%20for%20reporting%20obsolete%20Office%20365%20Groups%20and%20created%20a%20report%2C%20which%20might%20be%20easier%20to%20process%20than%20looking%20at%20PowerShell%20output.%20All%20improvements%20are%20gratefully%20accepted.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24Groups%20%3D%20Get-UnifiedGroup%0A%24Report%20%3D%20%40()%0A%24OrgName%20%3D%20(Get-OrganizationConfig).Name%0A%24Today%20%3D%20(Get-Date)%0A%24Date%20%3D%20%24Today.ToShortDateString()%0A%24ReportFile%20%3D%20%22c%3A%5Ctemp%5CListOfTeamEnabledGroups.html%22%0A%24htmlhead%3D%22%26lt%3Bhtml%26gt%3B%0A%20%20%20%20%26lt%3Bstyle%26gt%3B%0A%20%20%20%20BODY%7Bfont-family%3A%20Arial%3B%20font-size%3A%208pt%3B%7D%0A%20%20%20%20H1%7Bfont-size%3A%2022px%3B%20font-family%3A%20'Segoe%20UI%20Light'%2C'Segoe%20UI'%2C'Lucida%20Grande'%2CVerdana%2CArial%2CHelvetica%2Csans-serif%3B%7D%0A%20%20%20%20H2%7Bfont-size%3A%2018px%3B%20font-family%3A%20'Segoe%20UI%20Light'%2C'Segoe%20UI'%2C'Lucida%20Grande'%2CVerdana%2CArial%2CHelvetica%2Csans-serif%3B%7D%0A%20%20%20%20H3%7Bfont-size%3A%2016px%3B%20font-family%3A%20'Segoe%20UI%20Light'%2C'Segoe%20UI'%2C'Lucida%20Grande'%2CVerdana%2CArial%2CHelvetica%2Csans-serif%3B%7D%0A%20%20%20%20TABLE%7Bborder%3A%201px%20solid%20black%3B%20border-collapse%3A%20collapse%3B%20font-size%3A%208pt%3B%7D%0A%20%20%20%20TH%7Bborder%3A%201px%20solid%20%23969595%3B%20background%3A%20%23dddddd%3B%20padding%3A%205px%3B%20color%3A%20%23000000%3B%7D%0A%20%20%20%20TD%7Bborder%3A%201px%20solid%20%23969595%3B%20padding%3A%205px%3B%20%7D%0A%20%20%20%20td.pass%7Bbackground%3A%20%23B7EB83%3B%7D%0A%20%20%20%20td.warn%7Bbackground%3A%20%23FFF275%3B%7D%0A%20%20%20%20td.fail%7Bbackground%3A%20%23FF2626%3B%20color%3A%20%23ffffff%3B%7D%0A%20%20%20%20td.info%7Bbackground%3A%20%2385D4FF%3B%7D%0A%20%20%20%20%26lt%3B%2Fstyle%26gt%3B%0A%20%20%20%20%26lt%3Bbody%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdiv%20align%3Dcenter%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bp%26gt%3B%26lt%3Bh1%26gt%3BReport%20of%20Team-Enabled%20Office%20365%20Groups%26lt%3B%2Fh1%26gt%3B%26lt%3B%2Fp%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bp%26gt%3B%26lt%3Bh3%26gt%3BGenerated%3A%20%22%20%2B%20%24date%20%2B%20%22%26lt%3B%2Fh3%26gt%3B%26lt%3B%2Fp%26gt%3B%26lt%3B%2Fdiv%26gt%3B%22%0AWrite-Host%20%22Processing%22%20%24Groups.Count%20%22groups%22%0A%24TeamsFalse%20%3D%200%0A%24TeamsEnabled%20%3D%20%24False%0Aforeach%20(%24G%20in%20%24Groups)%20%7B%20%20%20%0A%20%20%20%20%20try%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%24teamschannels%20%3D%20Get-TeamChannel%20-GroupId%20%24G.ExternalDirectoryObjectId%0A%20%20%20%20%20%20%20%20%20%24TeamsEnabled%20%3D%20%24True%0A%20%20%20%20%20%20%20%20%20%7D%20catch%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%24ErrorCode%20%3D%20%24_.Exception.ErrorCode%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Switch%20(%24ErrorCode)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22404%22%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24TeamsEnabled%20%3D%20%24False%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24TeamsFalse%2B%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22403%22%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24TeamsEnabled%20%3D%20%24True%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20default%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Error%20(%22Unknown%20ErrorCode%20trying%20to%20'Get-TeamChannel%20-GroupId%20%7B0%7D'%20%3A%3A%20%7B1%7D%22%20-f%20%24G%2C%20%24ErrorCode)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20TeamEnabled%20%3D%20%24False%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%24ReportLine%20%3D%20New-Object%20PSObject%20-Property%20%40%7B%0A%20%20%20%20%20%20%20%20GroupName%20%20%20%20%20%20%20%20%20%20%20%3D%20%24G.DisplayName%0A%20%20%20%20%20%20%20%20ManagedBy%20%20%20%20%20%20%20%20%20%20%20%3D%20(Get-Mailbox%20-Identity%20%24G.ManagedBy%5B0%5D).DisplayName%0A%20%20%20%20%20%20%20%20Description%20%20%20%20%20%20%20%20%20%3D%20%24G.Notes%0A%20%20%20%20%20%20%20%20ExternalGuests%20%20%20%20%20%20%3D%20%24G.GroupExternalMemberCount%0A%20%20%20%20%20%20%20%20Members%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%24G.GroupMemberCount%0A%20%20%20%20%20%20%20%20TeamEnabled%20%20%20%20%20%20%20%20%20%3D%20%24TeamsEnabled%20%20%7D%20%20%20%20%20%20%0A%20%20%20%20%24Report%20%2B%3D%20%24ReportLine%20%20%20%20%20%20%20%20%0A%7D%0A%24GoodTeams%20%3D%20%24Groups.Count%20-%20%24TeamsFalse%0A%24PcentTeams%20%3D%20((%24GoodTeams%2F%24Groups.Count)*100)%0AWrite-Host%20%24GoodTeams%20%22of%20your%22%20%24Groups.Count%20%22Office%20365%20Groups%20are%20team-enabled%3B%20that's%22%20(%24GoodTeams%2F%24Groups.Count).tostring(%22P%22)%20%22of%20the%20total...%22%0A%23%20Create%20the%20HTML%20report%0A%24htmlbody%20%3D%20%24Report%20%7C%20ConvertTo-Html%20-Fragment%0A%24htmltail%20%3D%20%22%26lt%3Bp%26gt%3BReport%20created%20for%3A%20%22%20%2B%20%24OrgName%20%2B%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3B%2Fp%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bp%26gt%3BNumber%20of%20groups%20scanned%3A%20%20%20%20%20%20%20%20%20%20%20%20%22%20%2B%20%24Groups.Count%20%2B%20%22%26lt%3B%2Fp%26gt%3B%22%20%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%22%26lt%3Bp%26gt%3BNumber%20of%20Teams-enabled%20groups%20%20%20%20%3A%20%22%20%2B%20%24GoodTeams%20%2B%20%22%26lt%3B%2Fp%26gt%3B%22%20%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%22%26lt%3Bp%26gt%3BPercentage%20of%20Teams-enabled%20groups%3A%20%22%20%2B%20(%24GoodTeams%2F%24Groups.Count).tostring(%22P%22)%20%2B%20%22%26lt%3B%2Fbody%26gt%3B%26lt%3B%2Fhtml%26gt%3B%22%20%0A%24htmlreport%20%3D%20%24htmlhead%20%2B%20%24htmlbody%20%2B%20%24htmltail%0A%24htmlreport%20%7C%20Out-File%20%24ReportFile%20%20-Encoding%20UTF8%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141210%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141210%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%20Script%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3463%22%20target%3D%22_blank%22%3E%40David%20Whitney%3C%2FA%3E%20Thanks%20for%20sharing%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141034%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141034%22%20slang%3D%22en-US%22%3EAt%20this%20time%20I%20just%20wanted%20to%20provide%20it%20as%20an%20example%20snippet%2C%20but%20it%20may%20end%20up%20over%20in%20the%20gallery%20at%20some%20point.%20Thanks%20for%20the%20feedback!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141030%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141030%22%20slang%3D%22en-US%22%3ENice%20script...have%20you%20considered%20to%20upload%20to%20GitHub%20or%20the%20Microsoft%20TechNet%20Gallery%20and%20even%20pacakge%20all%20the%20staff%20in%20a%20PowerShell%20function%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-558442%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-558442%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%20I%20love%20this%20script.%20Thanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20a%20PS%20noob%20so%20i%20might%20be%20wrong%2C%20but%20I%20had%20to%20add%20resultsize%20parameter%20to%20unlimited%202%20time%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20top%20line%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24Groups%20%3D%20Get-UnifiedGroup%20-ResultSize%20Unlimited%3C%2FPRE%3E%3CP%3E%26nbsp%3BAnd%20in%20a%20later%20line%20(30)%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%20%24teamschannels%20%3D%20Get-TeamChannel%20-GroupId%20%24G.ExternalDirectoryObjectId%20-resultsize%20unlimted%20%3C%2FPRE%3E%3CP%3E%26nbsp%3BOr%20am%20i%20wrong%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-558539%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-558539%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F13305%22%20target%3D%22_blank%22%3E%40Jan%20KLaasen%3C%2FA%3E%26nbsp%3B%20Sure...%20that%20just%20makes%20sure%20you%20get%20all%20groups%20instead%20of%20just%20the%20first%201000%20(see%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fusers-and-groups%2Fget-unifiedgroup%3Fview%3Dexchange-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fusers-and-groups%2Fget-unifiedgroup%3Fview%3Dexchange-ps%3C%2FA%3E)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-580961%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-580961%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20thinks%20it%20is%20also%20needed%20with%20the%20get-mailbox%20command%20on%20line%2060.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20getting%3A%20WARNING%3A%20By%20default%2C%20only%20the%20first%201000%20items%20are%20returned.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-580993%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-580993%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F13305%22%20target%3D%22_blank%22%3E%40Jan%20KLaasen%3C%2FA%3E%26nbsp%3B%20Sure.%20The%20joy%20of%20PowerShell%20is%20that%20you%20can%20amend%20the%20code%20to%20meet%20your%20needs.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-632550%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-632550%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3463%22%20target%3D%22_blank%22%3E%40David%20Whitney%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20to%20add%20this%20script%20to%20technet.%20It%20would%20be%20my%20first%20but%20i%20have%20not%20enough%20credits%20there.%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20got%20the%3A%20%3CEM%3E%22Sorry%20you%20don%E2%80%99t%20have%20enough%20privileges%20to%20post%20an%20article%20on%20the%20Wiki.%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20thought%20i%20will%20post%20it%20here%20and%20hope%20it%20helps%20someone.%20What%20ii%20does%20is%20based%20on%20the%20script%20on%20this%20page%20add%20the%20Office%20365%20group%20to%20the%26nbsp%3BAzureADMSGroupLifecyclePolicy%20if%20it%20is%20not%20a%20Teams%20enabled%20group.%26nbsp%3BIf%20there%20are%20any%20mistakes%20or%20imporvemenst%20i%20made%20please%20let%20me%20know.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24PolicyId%20%3D%20(Get-AzureADMSGroupLifecyclePolicy).Id%3CBR%20%2F%3E%24TeamsFalse%20%3D%200%3CBR%20%2F%3E%24TeamsEnabled%20%3D%20%24False%3C%2FP%3E%3CP%3E%24groups%20%3D%20Get-UnifiedGroup%20-ResultSize%20unlimited%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Eforeach%20(%24g%20in%20%24groups)%7B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%23%20Add-AzureADMSLifecyclePolicyGroup%20-groupId%20%24g.ExternalDirectoryObjectId%20-id%20%24PolicyId%3CBR%20%2F%3E%3CBR%20%2F%3Etry%20%7B%3CBR%20%2F%3E%24teamschannels%20%3D%20Get-TeamChannel%20-GroupId%20%24g.ExternalDirectoryObjectId%3CBR%20%2F%3E%24TeamsEnabled%20%3D%20%24True%3CBR%20%2F%3E%7D%20catch%20%7B%3CBR%20%2F%3E%24ErrorCode%20%3D%20%24_.Exception.ErrorCode%3CBR%20%2F%3ESwitch%20(%24ErrorCode)%20%7B%3CBR%20%2F%3E%22404%22%20%7B%3CBR%20%2F%3E%24TeamsEnabled%20%3D%20%24False%3CBR%20%2F%3Ewrite-host%20%22Adding%3A%20%22%20%24g.ExternalDirectoryObjectId%3CBR%20%2F%3EAdd-AzureADMSLifecyclePolicyGroup%20-GroupId%20%24g.ExternalDirectoryObjectId%20-id%20%24PolicyId%3CBR%20%2F%3E%24TeamsFalse%2B%2B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%22403%22%20%7B%3CBR%20%2F%3Ewrite-host%20%22Removing%20(when%20necessary)%20%3A%20%22%20%24g.ExternalDirectoryObjectId%3CBR%20%2F%3ERemove-AzureADMSLifecyclePolicyGroup%20-GroupId%20%24g.ExternalDirectoryObjectId%20-id%20%24PolicyId%3CBR%20%2F%3E%24TeamsEnabled%20%3D%20%24True%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3Edefault%20%7B%3CBR%20%2F%3Ewrite-host%20%22Adding%3A%20%22%20%24g.ExternalDirectoryObjectId%3CBR%20%2F%3EAdd-AzureADMSLifecyclePolicyGroup%20-GroupId%20%24g.ExternalDirectoryObjectId%20-id%20%24PolicyId%3CBR%20%2F%3EWrite-Error%20(%22Unknown%20ErrorCode%20trying%20to%20'Get-TeamChannel%20-GroupId%20%7B0%7D'%20%3A%3A%20%7B1%7D%22%20-f%20%24G%2C%20%24ErrorCode)%3CBR%20%2F%3ETeamEnabled%20%3D%20%24False%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-643094%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-643094%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jan%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYour%20script%20is%20OK%20but%20I%20think%20we%20can%20improve%20it.%20First%2C%20the%20Get-Team%20cmdlet%20(since%200.96)%20is%20able%20to%20return%20a%20set%20of%20team-enabled%20groups%20for%20a%20tenant.%20Second%2C%20we%20can%20build%20in%20a%20mechanism%20to%20make%20sure%20that%20we%20don't%20try%20to%20add%20a%20team%20to%20the%20policy%20if%20it%20is%20already%20there.%20This%20is%20already%20explained%20in%20the%20Office%20365%20for%20IT%20Pros%20ebook%2C%20but%20to%20help%20everyone%2C%20I%20wrote%20up%20what%20I'd%20do%20on%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Foffice365itpros.com%2F2019%2F05%2F24%2Fpowershell-add-teams-groups-expiration-policy%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foffice365itpros.com%2F2019%2F05%2F24%2Fpowershell-add-teams-groups-expiration-policy%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20what%20you%20think.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-651865%22%20slang%3D%22en-US%22%3ERe%3A%20Teams-enabled%20O365%20Groups%20report%20workaround%20in%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-651865%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Tony%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20agree.%20Your%20way%20is%20much%20better.%20I%20will%20use%20it.%20I%20kinda%20was%20missing%20it%20in%20the%20book.%20Maybe%20it%20can%20be%20added%20there%20as%20well%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
David Whitney
Microsoft

Overdue Edit: As of version 0.9.6 of the MicrosoftTeams PowerShell module, the Get-Team command now returns all teams when run as an administrator. Graph API calls can also do this.

 

--

 

With the current (0.9.1) beta version of the Teams PowerShell module, as has been pointed out in other posts, the Get-Team command only returns Teams you -- the user running the command -- are a member of. However, as community member Nino Paulo found in another thread specific to the Graph API endpoint, we can use the error codes we get back from some of the related Teams commands to work around the current limitation. This can work for PowerShell as well, which may fit better into existing workflows and admin experience.

 

Following is a snippet that uses the Get-UnifiedGroup Exchange Online PS command to get all O365 Groups, then uses the Get-TeamChannel Microsoft Teams PS command across them and based on the response (no error, a 403 Access Denied error, or a 404 Not Found error) reports whether the O365 Group is TeamsEnabled. This can stand as its own .ps1, can fit into another script, or the output can be modified as needed (for example, output Primary SMTP rather than Azure AD Group ID). Note as written it does need to have an Exchange Online PS session and Microsoft Teams PS session already connected to work.

 

$o365groups = Get-UnifiedGroup
foreach ($o365group in $o365groups) {
    try {
        $teamschannels = Get-TeamChannel -GroupId $o365group.ExternalDirectoryObjectId
        [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; TeamsEnabled = $true}
    } catch {
        $ErrorCode = $_.Exception.ErrorCode
        switch ($ErrorCode) {
            "404" {
                [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; TeamsEnabled = $false}
                break;
            }
            "403" {
                [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; TeamsEnabled = $true}
                break;
            }
            default {
                Write-Error ("Unknown ErrorCode trying to 'Get-TeamChannel -GroupId {0}' :: {1}" -f $o365group, $ErrorCode)
            }
        }
    }
}

Sample output from the snippet:

GroupId                              GroupName    TeamsEnabled
-------                              ---------    ------------
399cd314-1c6d-4c8d-ad03-54a0ac07cc93 Test Group 1        False
6a175eba-02d9-44a7-b49e-ac71d7aeeaf7 Test Team            True

As with any example code, please test prior to production use.

17 Replies
Nice script...have you considered to upload to GitHub or the Microsoft TechNet Gallery and even pacakge all the staff in a PowerShell function?
At this time I just wanted to provide it as an example snippet, but it may end up over in the gallery at some point. Thanks for the feedback!

Great Script @David Whitney Thanks for sharing !

Thanks Dave, using Get-TeamChannel is an interesting way to figure out whether a group is team-enabled.

 

One of the wonders of PowerShell is how easy it is to take different bits of code and stitch them together. I took your code and some code I had for reporting obsolete Office 365 Groups and created a report, which might be easier to process than looking at PowerShell output. All improvements are gratefully accepted.

 

$Groups = Get-UnifiedGroup
$Report = @()
$OrgName = (Get-OrganizationConfig).Name
$Today = (Get-Date)
$Date = $Today.ToShortDateString()
$ReportFile = "c:\temp\ListOfTeamEnabledGroups.html"
$htmlhead="<html>
	   <style>
	   BODY{font-family: Arial; font-size: 8pt;}
	   H1{font-size: 22px; font-family: 'Segoe UI Light','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;}
	   H2{font-size: 18px; font-family: 'Segoe UI Light','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;}
	   H3{font-size: 16px; font-family: 'Segoe UI Light','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;}
	   TABLE{border: 1px solid black; border-collapse: collapse; font-size: 8pt;}
	   TH{border: 1px solid #969595; background: #dddddd; padding: 5px; color: #000000;}
	   TD{border: 1px solid #969595; padding: 5px; }
	   td.pass{background: #B7EB83;}
	   td.warn{background: #FFF275;}
	   td.fail{background: #FF2626; color: #ffffff;}
	   td.info{background: #85D4FF;}
	   </style>
	   <body>
           <div align=center>
           <p><h1>Report of Team-Enabled Office 365 Groups</h1></p>
           <p><h3>Generated: " + $date + "</h3></p></div>"
Write-Host "Processing" $Groups.Count "groups"
$TeamsFalse = 0
$TeamsEnabled = $False
foreach ($G in $Groups) {   
     try {       
         $teamschannels = Get-TeamChannel -GroupId $G.ExternalDirectoryObjectId
         $TeamsEnabled = $True
         } catch {
             $ErrorCode = $_.Exception.ErrorCode
             Switch ($ErrorCode) {
               "404" {
                   $TeamsEnabled = $False
                   $TeamsFalse++
                   break;
               }
               "403" {
                   $TeamsEnabled = $True
                   break;
               }
                default {
                Write-Error ("Unknown ErrorCode trying to 'Get-TeamChannel -GroupId {0}' :: {1}" -f $G, $ErrorCode)
                TeamEnabled = $False
               }                   
         }
    }
    $ReportLine = New-Object PSObject -Property @{
        GroupName           = $G.DisplayName
        ManagedBy           = (Get-Mailbox -Identity $G.ManagedBy[0]).DisplayName
        Description         = $G.Notes
        ExternalGuests      = $G.GroupExternalMemberCount
        Members             = $G.GroupMemberCount
        TeamEnabled         = $TeamsEnabled  }      
    $Report += $ReportLine        
}
$GoodTeams = $Groups.Count - $TeamsFalse
$PcentTeams = (($GoodTeams/$Groups.Count)*100)
Write-Host $GoodTeams "of your" $Groups.Count "Office 365 Groups are team-enabled; that's" ($GoodTeams/$Groups.Count).tostring("P") "of the total..."
# Create the HTML report
$htmlbody = $Report | ConvertTo-Html -Fragment
$htmltail = "<p>Report created for: " + $OrgName + "
             </p>
             <p>Number of groups scanned:            " + $Groups.Count + "</p>" +
             "<p>Number of Teams-enabled groups    : " + $GoodTeams + "</p>" +
             "<p>Percentage of Teams-enabled groups: " + ($GoodTeams/$Groups.Count).tostring("P") + "</body></html>"	
$htmlreport = $htmlhead + $htmlbody + $htmltail
$htmlreport | Out-File $ReportFile  -Encoding UTF8

 

Highlighted

@Tony Redmond : many thanks for this script ;)

 

"$" missed for "TeamsEnabled"

 

default {
                Write-Error ("Unknown ErrorCode trying to 'Get-TeamChannel -GroupId {0}' :: {1}" -f $G, $ErrorCode)
                TeamEnabled = $False

 

And it seems also know, we need to use this cmdlet to be able to use Microsoft Teams cmdlet requests :

 

Connect-MicrosoftTeams

 

https://docs.microsoft.com/en-us/powershell/module/teams/connect-microsoftteams?view=teams-ps

 

anyone faced this change too ? :) 

 

Thanks for feedback

 

1. You do need to connect to the Teams endpoint to use the Teams cmdlets (Get-Team etc.)

 

2. I don't recommend checking for channels any longer. It is more effective to look for the presence of the Team Chat folder in the group mailbox and see if any compliance items are in it because that will tell you that the team is used.

Thanks for you guidance ;)

 

I understand what is "Team Chat" folder in the group mailbox with an other great article from you as allways ... : https://www.petri.com/teams-compliance-story ;)

 

I understand the logic "because that will tell me that the team is used" but, is this "Team Chat" folder also present by default ? (for exemple : when we look at an "inactive" Teams-enabled O365 Groups)

The Team Chat folder might be present even if a group is not team enabled. I think groups created through OWA might provision the folder. In any case, it is best to check to see if compliance items are present. If the count is 0, then the team has never been used or the group is not team-enabled. A count > 1 means that someone has accessed the group and sent some messages.

Thank you ;)

By the way very happy to see you coming in France next month for MWC'18 and your session : Will Teams Take Over from Email ?!

 

je suis content d'etre a Paris pour mwc '18 aussi

@Tony Redmond  I love this script. Thanks @Tony Redmond 

I am a PS noob so i might be wrong, but I had to add resultsize parameter to unlimited 2 time 

 

In the top line:

 

$Groups = Get-UnifiedGroup -ResultSize Unlimited

 And in a later line (30): 

 

 $teamschannels = Get-TeamChannel -GroupId $G.ExternalDirectoryObjectId -resultsize unlimted 

 Or am i wrong?

@Tony Redmond 

I thinks it is also needed with the get-mailbox command on line 60. 

I am getting: WARNING: By default, only the first 1000 items are returned.

 

@digiweten  Sure. The joy of PowerShell is that you can amend the code to meet your needs.

@Tony Redmond @David Whitney 

I tried to add this script to technet. It would be my first but i have not enough credits there. 

And got the: "Sorry you don’t have enough privileges to post an article on the Wiki."

 

Then thought i will post it here and hope it helps someone. What ii does is based on the script on this page add the Office 365 group to the AzureADMSGroupLifecyclePolicy if it is not a Teams enabled group. If there are any mistakes or imporvemenst i made please let me know.

 

$PolicyId = (Get-AzureADMSGroupLifecyclePolicy).Id
$TeamsFalse = 0
$TeamsEnabled = $False

$groups = Get-UnifiedGroup -ResultSize unlimited


foreach ($g in $groups){


# Add-AzureADMSLifecyclePolicyGroup -groupId $g.ExternalDirectoryObjectId -id $PolicyId

try {
$teamschannels = Get-TeamChannel -GroupId $g.ExternalDirectoryObjectId
$TeamsEnabled = $True
} catch {
$ErrorCode = $_.Exception.ErrorCode
Switch ($ErrorCode) {
"404" {
$TeamsEnabled = $False
write-host "Adding: " $g.ExternalDirectoryObjectId
Add-AzureADMSLifecyclePolicyGroup -GroupId $g.ExternalDirectoryObjectId -id $PolicyId
$TeamsFalse++
break;
}
"403" {
write-host "Removing (when necessary) : " $g.ExternalDirectoryObjectId
Remove-AzureADMSLifecyclePolicyGroup -GroupId $g.ExternalDirectoryObjectId -id $PolicyId
$TeamsEnabled = $True
break;
}
default {
write-host "Adding: " $g.ExternalDirectoryObjectId
Add-AzureADMSLifecyclePolicyGroup -GroupId $g.ExternalDirectoryObjectId -id $PolicyId
Write-Error ("Unknown ErrorCode trying to 'Get-TeamChannel -GroupId {0}' :: {1}" -f $G, $ErrorCode)
TeamEnabled = $False
}
}


}

}

Hi Jan,

 

Your script is OK but I think we can improve it. First, the Get-Team cmdlet (since 0.96) is able to return a set of team-enabled groups for a tenant. Second, we can build in a mechanism to make sure that we don't try to add a team to the policy if it is already there. This is already explained in the Office 365 for IT Pros ebook, but to help everyone, I wrote up what I'd do on https://office365itpros.com/2019/05/24/powershell-add-teams-groups-expiration-policy/

 

See what you think.

@Tony Redmond 

 

Hi Tony, 

I agree. Your way is much better. I will use it. I kinda was missing it in the book. Maybe it can be added there as well?

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies