Teams T2T Migration, set Owner and list Owners and Members
# Get all the teams from tenant
$teams=Get-Team
#Add migration GA as Owner
$Teams | Add-TeamUser -user USERACCOUNT -Role Owner
# Loop through the teams
foreach($team in $teams)
{
Write-Host -ForegroundColor Magenta "Getting all the owners from Team: " $team.DisplayName
# Get the team owners
$ownerColl= Get-TeamUser -GroupId $team.GroupId -Role Owner
#Loop through the owners
foreach($owner in $ownerColl)
{
Write-Host -ForegroundColor Yellow "User ID: " $owner.UserId " User: " $owner.User " Name: " $owner.Name
}
}
# Loop through the teams
foreach($team in $teams)
{
Write-Host -ForegroundColor Magenta "Getting all the members from Team: " $team.DisplayName
# Get the team owners
$memberColl= Get-TeamUser -GroupId $team.GroupId -Role Member
#Loop through the owners
foreach($member in $memberColl)
{
Write-Host -ForegroundColor Yellow "User ID: " $member.UserId " User: " $member.User " Name: " $member.Name
}
}