In this blog, you will see how to get the team owners from all the teams using PowerShell.
Prerequisites
Install the Teams Cmdlets module.
Reference URL: https://www.powershellgallery.com/packages/MicrosoftTeams/1.0.5
PowerShell Script
Open Notepad and paste the following script. Save the file as Teams.ps1.
  1. # Get the credentials
  2. $credentials=Get-Credential
  3. # Connect to Microsoft Teams
  4. Connect-MicrosoftTeams -Credential $credentials
  5. # Get all the teams from tenant
  6. $teamColl=Get-Team
  7. # Loop through the teams
  8. foreach($team in $teamColl)
  9. {
  10. Write-Host -ForegroundColor Magenta "Getting all the owners from Team: " $team.DisplayName
  11. # Get the team owners
  12. $ownerColl= Get-TeamUser -GroupId $team.GroupId -Role Owner
  13. #Loop through the owners
  14. foreach($owner in $ownerColl)
  15. {
  16. Write-Host -ForegroundColor Yellow "User ID: " $owner.UserId " User: " $owner.User " Name: " $owner.Name
  17. }
  18. }
Open Windows PowerShell window and navigate to the location where the script file was saved.
Run the following command.
  1. .\Teams.ps1
Result
Summary
Thus, in this blog, you saw how to get the team owners from all the teams using PowerShell.