Feb 27 2020 06:29 AM
If I have all the IDs for my teams in a csv, how do I use something like this to just pull out the owners?
Get-TeamUser -GroupId [team ID goes here] -Role Owner
Outcome I want is to be able to email them all with a message about a change to the service.
If it's not obvious, I'm not a powershell guy. This is also helping me plug a gap in a far more technical challenge of reporting on connected apps without having to master the Graph API or buy a tool to do it. I'm keeping it low-tech, I'm going to ask people!
Thanks, Darrel
Feb 27 2020 06:59 AM
Hi,
If you want E-mail addresses for all Team Owners you could do something like this. You have to connect to Azure AD Powershell and Teams powershell first.
$Users = (Get-Team | Get-TeamUser -Role owner).user
foreach($User in $Users)
{
Get-AzureADUser -ObjectID $User | Select Mail
}
But do you only want the owners for the Teams that you have in the CSV or is this Okay?
Feb 27 2020 10:25 AM
@Linus Cansby good question, your suggestion is also useful. Our set up is that Teams admin have Team admin plus SharePoint admin. Very frustrating trying to do anything with the AAD commands because we're missing the exchange role.
Ideally I'd like to loop through a predefined list of Teams IDs.
Feb 27 2020 01:18 PM
SolutionIf you want to only get owners for some teams that you have in a CSV with a header called GroupID you can to it like this:
$GroupIDs = Import-Csv -Path C:\PathToCSV\Teams.csv
foreach($Group in $GroupIDs)
{
$Owners = Get-Team -GroupId $Group.GroupID | Get-TeamUser -Role Owner
foreach ($Owner in $Owners)
{
Get-AzureADUser -ObjectID $Owner.User | Select Mail
}
}
But you still need to connect to Azure AD with powershell (only read access) and Teams (only read access).
Feb 27 2020 01:18 PM
SolutionIf you want to only get owners for some teams that you have in a CSV with a header called GroupID you can to it like this:
$GroupIDs = Import-Csv -Path C:\PathToCSV\Teams.csv
foreach($Group in $GroupIDs)
{
$Owners = Get-Team -GroupId $Group.GroupID | Get-TeamUser -Role Owner
foreach ($Owner in $Owners)
{
Get-AzureADUser -ObjectID $Owner.User | Select Mail
}
}
But you still need to connect to Azure AD with powershell (only read access) and Teams (only read access).