May 25 2020 04:11 AM
Grateful for any help in helping me solve a task for my org.
The task is to find out if a group of email addresses are Team owners and of what Teams.
I could go one by one and work it out but I'd like something repeatable to run as a report based on a stakeholder providing me with a list of email addresses.
I only have Teams admin and SharePoint admin roles.
Thanks, Darrel
May 29 2020 02:26 AM
I got the result I wanted. It might not be pretty but it works.
#Start here and change role to "Member" if want member
Connect-AzureAD
Connect-MicrosoftTeams
$Owner = 'name@yourorg.com'
$Groups = Get-AzureADUser -ObjectId $Owner | Get-AzureADUserMembership | Where-Object {$_.ObjectType -eq 'Group'}
$Results = $Groups | ForEach-Object {
$TeamID = $_.ObjectID
$TeamMembers = Get-TeamUser -GroupId $TeamID
$IsOwner = $TeamMembers | Where-Object { $_.User -eq $Owner -and $_.Role -eq "Owner"}
if ($IsOwner) {
try {
Get-Team -GroupID $TeamID | Select-Object -Property DisplayName, Description, Visibility, MailNickName, Classification
}
catch
{}
}
}
if (-not($Results))
{
Write-Host "$Owner isn’t an owner/member of any Microsoft Team (depending on role you select)"
} Else {
Write-Host $Owner
$Results
}
May 29 2020 08:26 AM
SolutionIf you want to use the Azure AD cmdlets, Get-AzureADUserOwnedObject should be the fastest way. Best use Exchange PowerShell though:
Get-UnifiedGroup -Filter "ManagedBy -eq '$dn' -and ResourceProvisioningOptions -eq 'Team'"
where $dn is the DistinguishedName of the user you want to check against.
Jun 01 2020 12:11 AM
@Vasil Michev thanks. I've sort of muddled through part of that but couldn't get your quickest method to work. I connected to an online session with the correct role and no joy running it. Would I be correct in saying dn is the username I want to check against i.e firstname.lastname@org.com
Jun 01 2020 08:17 AM
No, it's the DistinguishedName attribute:
$dn = (Get-Mailbox user@domain.com).DistinguishedName
May 29 2020 08:26 AM
SolutionIf you want to use the Azure AD cmdlets, Get-AzureADUserOwnedObject should be the fastest way. Best use Exchange PowerShell though:
Get-UnifiedGroup -Filter "ManagedBy -eq '$dn' -and ResourceProvisioningOptions -eq 'Team'"
where $dn is the DistinguishedName of the user you want to check against.