'PowerShell Get-Team Display Name from GroupID

Good afternoon all,

Would greatly appreciate your help and perhaps a little of your patience as i am very very new to Powershell.

I am trying to export a .csv list of MS Teams 'Owners' and their 'Team Names'. Whilst i have the team owners:

$TeamOwner = (Get-TeamUser -GroupID TEAM_ID_HERE | Where-object {$_.Role -eq 'Owner'}.User

I cannot seem to get the 'DisplayName' from the the GroupID. My latest attempt loos like:

$TeamName = (Get-Team -GroupId TEAM_ID_HERE | select DisplayName).DisplayName - but this is really a stab in the dark from multiple existing threads.

ANy help on returning a DisplayName from the GroupID would be most welcome.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source