Microsoft Tech Community Live:  Microsoft Teams Edition
November 09, 2021, 08:00 AM - 12:00 PM (PST)
SOLVED

Any way to get a list of all Teams a user is a member of?

%3CLINGO-SUB%20id%3D%22lingo-sub-309807%22%20slang%3D%22en-US%22%3EAny%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-309807%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20we%20have%20someone%20leave%20our%20company%2C%20we%20want%20to%20go%20in%20and%20clean%20up%20any%20Teams%20their%20account%20was%20a%20member%20of%20so%20it%20doesn't%20end%20up%20as%20an%20Unknown%20User.%26nbsp%3B%20Is%20there%20a%20way%20to%20get%20a%20list%20of%20all%20Teams%20someone%20is%20on%3F%26nbsp%3B%20Similar%20to%20in%20AD%20and%20going%20to%20the%20%22Member%20Of%22%20tab%20to%20see%20AD%20groups%20someone%20is%20in%20maybe%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-309807%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-310410%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-310410%22%20slang%3D%22en-US%22%3E%3CP%3ESorry%20to%20disappoint.%20On%20the%20upside%2C%20we%20found%20a%20bug%20in%20Get-Team%20that%20will%20now%20be%20fixed.%20Extending%20Get-Team%20to%20return%20a%20set%20of%20teams%20that%20someone%20belongs%20to%20is%20another%20matter%2C%20but%20the%20ask%20has%20been%20made.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-310408%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-310408%22%20slang%3D%22en-US%22%3EWhen%20I%20saw%20your%20reply%20I%20thought%20it%20had%20been%20fixed%20too.%20Too%20bad.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-310180%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-310180%22%20slang%3D%22en-US%22%3EOh%2C%20i%20was%20awake%20of%20this%20but%20somehow%20believed%20this%20was%20fixed%20by%20now%20%F0%9F%A4%B7%E2%80%8D%E2%99%82%3CBR%20%2F%3E%3CBR%20%2F%3E%EF%B8%8FAdam%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-310170%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-310170%22%20slang%3D%22en-US%22%3E%3CP%3EI%20posted%20a%20reply%20about%20using%20Get-Team%20-User%20to%20find%20the%20teams%20that%20someone%20belongs%20to%2C%20but%20of%20course%20(as%20I%20should%20have%20known%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fteams%2Fget-team%3Fview%3Dteams-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fteams%2Fget-team%3Fview%3Dteams-ps%3C%2FA%3E%20tells%20us%20that%20the%20-User%20parameter%20only%20accepts%20the%20UPN%20of%20the%20current%20user.%20In%20fact%2C%20it%20doesn't%2C%20as%20you%20can%20input%20any%20name%20you%20like%2C%20but%20the%20cmdlet%20still%20only%20returns%20the%20list%20of%20teams%20that%20the%20currently%20signed%20in%20user%20belongs%20to.%20It's%20a%20bug.%20I%20will%20signal%20it%20to%20Microsoft.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-309932%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-309932%22%20slang%3D%22en-US%22%3E%3CP%3ECorrect.%20However%2C%20if%20all%20you%20want%20to%20do%20is%20quickly%20check%20what%20Groups%20someone%20belongs%20to%2C%20you%20can%20do%20this%20with%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24Mailbox%20%3D%20Read-Host%20%22Enter%20User%20to%20check%22%0A%24DN%20%3D%20(Get-Mailbox%20-Identity%20%24Mailbox).DistinguishedName%0A%24Groups%20%3D%20(Get-Recipient%20-RecipientTypeDetails%20GroupMailbox%20-Filter%20%22Members%20-eq%20'%24DN'%22%20%7C%20Select%20DisplayName%2C%20Alias)%0AWrite-Host%20%24Mailbox%20%22is%20a%20member%20of%22%20%24Groups.count%20%22Groups%22%0A%24Groups%20%7C%20Select%20DisplayName%2C%20Alias%3C%2FPRE%3E%0A%3CP%3EGetting%20a%20list%20of%20Teams%20isn't%20quite%20as%20simple%20because%20the%20Get-Recipient%20cmdlet%20doesn't%20support%20Teams%20and%20Teams%20doesn't%20support%20filtering%20by%20distinguished%20name.%20But%20it's%20possible%20with%20something%20like%3A%3C%2FP%3E%0A%3CPRE%3E%24Mailbox%20%3D%20Read-Host%20%22Enter%20User%20to%20check%22%0A%24UserId%20%3D%20(Get-Mailbox%20-Identity%20%24Mailbox).ExternalDirectoryObjectId%0A%24Teams%20%3D%20Get-Team%0AForEach%20(%24T%20in%20%24Teams)%20%7B%0A%20%20%20%20%24TeamUsers%20%3D%20(Get-TeamUser%20-GroupId%20%24T.GroupId%20%7C%20Select%20UserId)%20%0A%20%20%20%20If%20(%24TeamUsers%20-Match%20%24UserId)%20%7B%0A%20%20%20%20%20%20%20%20Write-Host%20%24Mailbox%20%22found%20in%22%20%24T.DisplayName%7D%0A%7D%3C%2FPRE%3E%0A%3CP%3EFor%20more%2C%20see%20Chapter%2014%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fgum.co%2FO365IT%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EOffice%20365%20for%20IT%20Pros%3C%2FA%3E%20eBook.%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22CodeCxSpFirst%22%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-309923%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-309923%22%20slang%3D%22en-US%22%3EAs%20an%20alternative%20to%20PS%20cmdlets%2C%20you%20also%20have%20the%20power%20of%20the%20Graph%20API%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-309843%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-309843%22%20slang%3D%22en-US%22%3EYes%20and%20no!%20Through%20here%20you%20can%20see%20all%20the%20groups%20the%20member%20of%20but%20they%20don%E2%80%99t%20necessarily%20mean%20Teams!%3CBR%20%2F%3E%3CBR%20%2F%3EAdam%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-309831%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-309831%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20see%20this%20in%20the%20Microsoft%20365%20Admin%20center.%20Find%20the%20user%2C%20click%20on%20their%20name%2C%20and%20it%20will%20show%20you%26nbsp%3Btheir%20groups.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20481px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F64834iA47E60EF6018368F%2Fimage-dimensions%2F481x260%3Fv%3D1.0%22%20width%3D%22481%22%20height%3D%22260%22%20alt%3D%22GroupMembership.PNG%22%20title%3D%22GroupMembership.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-309815%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-309815%22%20slang%3D%22en-US%22%3EPlease%20have%20a%20look%20at%20these%20powershell%20cmdlets%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fteams%2Fget-team%3Fview%3Dteams-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fteams%2Fget-team%3Fview%3Dteams-ps%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAdam%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-903742%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-903742%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F47110%22%20target%3D%22_blank%22%3E%40Mike%20Boehm%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20you%20get%20an%20answer%20%2F%20solution%20for%20this%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-994467%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-994467%22%20slang%3D%22en-US%22%3EYou%20will%20need%20Teams%20PS%20Module%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoftTeams%2F1.0.2%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoftTeams%2F1.0.2%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EConnect-MicrosoftTeams%3CBR%20%2F%3EGet-Team%20-User%20%3CUPN%3E%20%7C%20fl%3CBR%20%2F%3E%3CBR%20%2F%3EShows%20all%20Teams%20a%20User%20is%20member%20in.%3CBR%20%2F%3E%3CBR%20%2F%3ERegards%3C%2FUPN%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1010577%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1010577%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F344867%22%20target%3D%22_blank%22%3E%40Philip_Moritz85%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20would%20be%20great%20if%20it%20were%20so%20easy.%3C%2FP%3E%3CP%3EI%20just%20tried%20that%2C%20but%20it%20also%20seems%20to%20(additionally%3F!%3F)%20show%20the%20Teams%20my%20user%20is%20a%20member%20of.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EReally%20weird...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1010744%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1010744%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F291621%22%20target%3D%22_blank%22%3E%40SChauhan%3C%2FA%3E%26nbsp%3BGet-Team%20-User%20is%20intended%20to%20list%20all%20the%20teams%20a%20user%20belongs%20to.%20What%20do%20you%20want%20to%20do%20if%20that%20not%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1011108%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1011108%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%3BIt%20did%20not%20only%20list%20the%20groups%20for%20the%20UPN%20I%20supplied%20but%20also%20for%20the%20user%20I%20was%20running%20the%20query%20with.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUPN%20is%20in%20groups%20A%2CB%2CC%20and%20D%3C%2FP%3E%3CP%3EExecuting%20User%20is%20in%20D%2C%20E%20and%20F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResult%3A%26nbsp%3B%3C%2FP%3E%3CP%3EA%3C%2FP%3E%3CP%3EB%3C%2FP%3E%3CP%3EC%3C%2FP%3E%3CP%3ED%3C%2FP%3E%3CP%3EE%3C%2FP%3E%3CP%3EF%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1011137%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1011137%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F291621%22%20target%3D%22_blank%22%3E%40SChauhan%3C%2FA%3E%26nbsp%3BCongratulations.%20You%20find%20a%20regression...%20and%20it's%20in%20the%20latest%20beta%20version%20of%20the%20Teams%20PowerShell%20module.%20I%20shall%20let%20the%20powers%20that%20be%20know.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20meantime%2C%20you%20can%20use%20the%20workaround%20that%20I%20documented%20in%20a%20previous%20reply%20to%20search%20the%20membership%20of%20Azure%20AD%20Groups%20for%20a%20user's%20distinguished%20name.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2194587%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2194587%22%20slang%3D%22en-US%22%3E%3CP%3EFor%20the%20record%2C%20this%20worked%20for%20me%20(MicrosoftTeams%20module%201.1.10-preview%20installed%2C%20PowerShell%205.1)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBLAH%20get%3D%22%22%20admin%3D%22%22%20user%3D%22%22%20credentials%3D%22%22%3E%3C%2FBLAH%3E%3C%2FP%3E%3CP%3EConnect-MicrosoftTeams%20-Credential%20%24UserCredential%3C%2FP%3E%3CP%3EGet-Team%20%7C%20Get-Member%20%23What%20properties%20are%20there%3F%3C%2FP%3E%3CP%3E%23Uncomment%20one%3A%3C%2FP%3E%3CP%3E%23Get-Team%20-User%20%24MyUser%7C%20fl%20%23List%20of%20all%20properties%20and%20values%20for%20%24MyUser%3C%2FP%3E%3CP%3E%23Get-Team%20-User%20%24MyUser%7C%20Format-Table%20DisplayName%20-AutoSize%20%23Only%20the%20properties%20I%20list%2C%20e.g.%20DisplayName%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EProblem%3A%20My%20actual%20intention%20was%20to%20find%20out%20what%20Teams%20this%20member%20was%20an%20Owner%20of.%20DisplayName%20is%20only%20part%20of%20the%20problem.%20It%20wasn't%20clear%20from%20the%20properties%20in%20Get-Member%20how%20to%20find%20the%20permissions%20level%20on%20the%20listed%20Team.%20Any%20suggestions%20on%20pulling%20that%20rather%20important%20bit%20of%20information%3F%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2194590%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2194590%22%20slang%3D%22en-US%22%3ETry%20the%20techniques%20in%20%3CA%20href%3D%22https%3A%2F%2Foffice365itpros.com%2F2021%2F02%2F23%2Fmicrosoft-365-groups-membership-report%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foffice365itpros.com%2F2021%2F02%2F23%2Fmicrosoft-365-groups-membership-report%2F%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2194891%22%20slang%3D%22en-US%22%3ERe%3A%20Any%20way%20to%20get%20a%20list%20of%20all%20Teams%20a%20user%20is%20a%20member%20of%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2194891%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%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!%20Looking%20forward%20to%20making%20sense%20of%20this%20and%20testing%20it%20out.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Super Contributor

When we have someone leave our company, we want to go in and clean up any Teams their account was a member of so it doesn't end up as an Unknown User.  Is there a way to get a list of all Teams someone is on?  Similar to in AD and going to the "Member Of" tab to see AD groups someone is in maybe?

18 Replies

You can see this in the Microsoft 365 Admin center. Find the user, click on their name, and it will show you their groups.

 

.GroupMembership.PNG

Yes and no! Through here you can see all the groups the member of but they don’t necessarily mean Teams!

Adam
As an alternative to PS cmdlets, you also have the power of the Graph API
best response confirmed by Kevin Crossman (MVP)
Solution

Correct. However, if all you want to do is quickly check what Groups someone belongs to, you can do this with:

 

$Mailbox = Read-Host "Enter User to check"
$DN = (Get-Mailbox -Identity $Mailbox).DistinguishedName
$Groups = (Get-Recipient -RecipientTypeDetails GroupMailbox -Filter "Members -eq '$DN'" | Select DisplayName, Alias)
Write-Host $Mailbox "is a member of" $Groups.count "Groups"
$Groups | Select DisplayName, Alias

Getting a list of Teams isn't quite as simple because the Get-Recipient cmdlet doesn't support Teams and Teams doesn't support filtering by distinguished name. But it's possible with something like:

$Mailbox = Read-Host "Enter User to check"
$UserId = (Get-Mailbox -Identity $Mailbox).ExternalDirectoryObjectId
$Teams = Get-Team
ForEach ($T in $Teams) {
    $TeamUsers = (Get-TeamUser -GroupId $T.GroupId | Select UserId) 
    If ($TeamUsers -Match $UserId) {
        Write-Host $Mailbox "found in" $T.DisplayName}
}

For more, see Chapter 14 of the Office 365 for IT Pros eBook. 

 

I posted a reply about using Get-Team -User to find the teams that someone belongs to, but of course (as I should have known, https://docs.microsoft.com/en-us/powershell/module/teams/get-team?view=teams-ps tells us that the -User parameter only accepts the UPN of the current user. In fact, it doesn't, as you can input any name you like, but the cmdlet still only returns the list of teams that the currently signed in user belongs to. It's a bug. I will signal it to Microsoft.

Oh, i was awake of this but somehow believed this was fixed by now 🤷‍:male_sign:

Adam
When I saw your reply I thought it had been fixed too. Too bad.

Sorry to disappoint. On the upside, we found a bug in Get-Team that will now be fixed. Extending Get-Team to return a set of teams that someone belongs to is another matter, but the ask has been made.

@Mike Boehm 

 

Did you get an answer / solution for this ?

You will need Teams PS Module
https://www.powershellgallery.com/packages/MicrosoftTeams/1.0.2

Connect-MicrosoftTeams
Get-Team -User <UPN> | fl

Shows all Teams a User is member in.

Regards

@Deleted 

 

That would be great if it were so easy.

I just tried that, but it also seems to (additionally?!?) show the Teams my user is a member of.

 

Really weird...

@SChauhan Get-Team -User is intended to list all the teams a user belongs to. What do you want to do if that not?

@Tony Redmond It did not only list the groups for the UPN I supplied but also for the user I was running the query with.

 

UPN is in groups A,B,C and D

Executing User is in D, E and F

 

Result: 

A

B

C

D

E

F

@SChauhan Congratulations. You find a regression... and it's in the latest beta version of the Teams PowerShell module. I shall let the powers that be know.

 

In the meantime, you can use the workaround that I documented in a previous reply to search the membership of Azure AD Groups for a user's distinguished name.

For the record, this worked for me (MicrosoftTeams module 1.1.10-preview installed, PowerShell 5.1):

#get admin user credentials, stuff into $UserCredential, get user's email stuff into $MyUser
Connect-MicrosoftTeams -Credential $UserCredential
Get-Team | Get-Member #What properties are there?
#Uncomment one:
#Get-Team -User $MyUser| fl #List of all properties and values for $MyUser
#Get-Team -User $MyUser| Format-Table DisplayName -AutoSize #Only the properties I list, e.g. DisplayName

Problem: My actual intention was to find out what Teams this member was an Owner of. DisplayName is only part of the problem. It wasn't clear from the properties in Get-Member how to find the permissions level on the listed Team. Any suggestions on pulling that rather important bit of information? Thanks!

Thanks @Tony Redmond! Looking forward to making sense of this and testing it out.