In this blog, you will see how to get the team owners from all the teams using PowerShell.
Prerequisites
Install the Teams Cmdlets module.
PowerShell Script
Open Notepad and paste the following script. Save the file as Teams.ps1.
- # Get the credentials
- $credentials=Get-Credential
- # Connect to Microsoft Teams
- Connect-MicrosoftTeams -Credential $credentials
- # Get all the teams from tenant
- $teamColl=Get-Team
- # Loop through the teams
- foreach($team in $teamColl)
- {
- Write-Host -ForegroundColor Magenta "Getting all the owners from Team: " $team.DisplayName
- # Get the team owners
- $ownerColl= Get-TeamUser -GroupId $team.GroupId -Role Owner
- #Loop through the owners
- foreach($owner in $ownerColl)
- {
- Write-Host -ForegroundColor Yellow "User ID: " $owner.UserId " User: " $owner.User " Name: " $owner.Name
- }
- }
Open Windows PowerShell window and navigate to the location where the script file was saved.
Run the following command.
- .\Teams.ps1
Result
Summary
Thus, in this blog, you saw how to get the team owners from all the teams using PowerShell.

R WPosted Apr 28, 2021, 6:41 PM
Is it possible to edit the script to include Output to CSV?