If you administer Microsoft Teams, the day where you’ll need to know how to get all Teams a user is a member of can come in handy. Today we’re going to share exactly this can be done quickly and efficiently using Powershell.
Before we start, you’ll need to install the Microsoft Teams Module for Powershell. Assuming you have the required roles assigned, this should give you everything you need to be up and running in no time.
As mentioned, you’ll need to make sure you have the permissions as well as the module installed but lets lay that out here in an easy to view format.
- Teams Administrator Role -or- Global Admin Role
- Microsoft Teams Powershell Module
Now that we have this completed lets move on to the next piece which is actually showing you a way to see what teams a user is a member of.
Get All Teams A User Is A Member Of
Luckily for us Microsoft really made this easy because we can use a single cmdlet to this information. I’ve seen other places online where people write hundreds of lines of code to get this information and it’s simply not needed.
Get-Team -User [email protected]
Get All Members of a Team
Bonus. We can use this GroupId to get all the members of a Team. This time instead of Get-Team -User <UserPrincipalName> we’ll be utilizing Get-TeamUser -GroupId <GroupId>
Get-TeamUser -GroupId <groupid>
As you can see here we’ve figured out a way to get all the Teams a user is a member of. We’ve also figured out all the members of a Team by using the GroupId associated with the Team.
Hopefully, this information will come in handy and will allow you to administer Teams in a more efficient way using Powershell. I’ve always been a fan of PS because it allows you to automate and make change in bulk. If you liked articles like this, feel free to check out our Teams Gallery. Not to mention the Sysadmin Channel for awesome video content.