Forum Discussion

DazzaR's avatar
DazzaR
Steel Contributor
Feb 27, 2020
Solved

Powershell question about getting all Team owners so I can email them

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 t...
  • LinusCansby's avatar
    LinusCansby
    Feb 27, 2020

    If 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).

Resources