Forum Discussion
TonyRedmond
Dec 20, 2018MVP
Using PowerShell to Check Group or Team Membership
PowerShell is great at getting lots done for Office 365 administrators. As an example, here are a couple of ways to check the membership of an Office 365 Group or a Microsoft Team to find out whether...
ashokjingar
Jun 20, 2019Copper Contributor
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
praestegaard
Apr 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