Forum Discussion
Using PowerShell to Check Group or Team Membership
Hi Tony,
I've seen a few of your wonderful scripts to do with Groups and Teams hence I feel you are the best person to ask this. Is it possible via PowerShell to get a list of Teams and what Groups they have residing in them.
I know that within Microsoft Teams, you can add members to a Team, which can be individuals and Groups. It is those groups that were added that I need to see. Is this possible?
Thank you in advance,
Ash
- praestegaardApr 01, 2020Copper Contributor
ashokjingar I just stumpled upon this thread and registered myself to tell you that theres a module that lets you fetch Office 365 groups that are used for abstracting a membership of af Teams team.
'MicrosoftTeams' | ForEach-Object -Process { if (-not (Get-Module -name $_ -ListAvailable)) { Install-Module -Name $_ -Scope CurrentUser } Import-Module -Name $_ -ErrorAction Stop } $connection = Get-Variable -Name connection -ValueOnly -ErrorAction SilentlyContinue if (-not $connection) { Write-Host -Object "There might be a MS login pop-up window that you havent noticed" -BackgroundColor Yellow -ForegroundColor Black $connection = Connect-MicrosoftTeams -ErrorAction Stop } #endregion Init Write-Host -Object 'Fetching all Teams groups' $team = Get-Team Write-Host -Object 'Fetching all Teams groupmembers' $teamUser = $team | Get-TeamUser
-Anders
- Jun 20, 2019I doubt this because you actually aren’t adding any groups to teams!
you’re just doing a one time import of the member of those groups. So you’ll probably just see the members being added- ashokjingarJun 20, 2019Copper Contributor
Thanks for your reply. If you read the following article, TonyRedmond makes a comment that in Azure AD, background synchronisation takes place eventually. Meaning that if you add a new user to a particular Group in Azure AD, that new user should eventually appear in the Team that uses that Group. So that would imply that Teams/Azure AD knows which Groups belong to which Team.
Regards,
Ash
- Jun 20, 2019Yes! There’s always a Office 365 group for every team! But you can’t add another group in the members section! Only add users or groups but it will then only import the users that are members of that group
You should be able to get the underlaying office365 groups for the teams