Introduction:
In today’s collaborative digital landscape, Microsoft Teams has emerged as a powerful platform for effective communication and seamless teamwork. As organizations embrace Teams, there is often a need to add multiple users as owners to various Teams sites. Manually performing this task can be time-consuming and prone to errors. However, in this blog post, we will explore a streamlined solution to add bulk users from a text file to Teams sites as owners, saving you valuable time and effort.
Prerequisites:
To follow along with the steps outlined in this blog post, you will need the following:
- A text file containing the list of Teams sites to which you want to add owners.
- The email address of the owner(s) to be added.
Let’s get started!
Step 1: Prepare the Text File:
First, ensure that you have a text file ready with the names of the Teams sites, each on a separate line. Make sure the file is easily accessible, and remember its location.
Step 2: Run the PowerShell Script:
- Open a PowerShell window or editor of your choice.
- Copy the provided script into the PowerShell window or editor.
# Prompt for the path to the text file containing the list of Teams $teamNamesFilePath = Read-Host "Enter the path to the text file containing the list of Teams" # Read the list of Team names from a text file $teamNames = Get-Content -Path $teamNamesFilePath # Prompt for the email address of the owner to add $ownerEmail = Read-Host "Enter the email address of the owner to add" # Connect to Microsoft Teams Connect-MicrosoftTeams # Loop through the Teams based on the names in the file and add owner foreach ($teamName in $teamNames) { # Retrieve the Team based on the name $team = Get-Team -DisplayName $teamName # Check if Team exists if ($team -eq $null) { Write-Host "Team not found: $teamName" continue } # Add owner to the Team using the Team ID and owner email address Add-TeamUser -GroupId $team.GroupId -User $ownerEmail -Role Owner Write-Host "Owner added to Team: $($team.DisplayName)" } # Pause the script and wait for user input before closing the window Read-Host "Press Enter to exit"
Step 3: Provide the Required Information:
- When prompted, enter the path to the text file containing the list of Teams site names.
- Enter the email address of the owner(s) you want to add.
Step 4: Execute the Script:
- After providing the necessary information, execute the script by pressing Enter.
- The script will connect to Microsoft Teams using the Connect-MicrosoftTeams cmdlet.
- It will then loop through the Teams site names in the text file, checking if each exists.
- If a Team site is found, the owner(s) will be added using the Add-TeamUser cmdlet with the specified email address and the “Owner” role.
Step 5: Review and Verify:
- During the script execution, you will see progress updates and notifications for each Team site being processed.
- After completion, review the output to ensure that all owners were successfully added to the respective Teams sites.
Conclusion:
Automating the process of adding bulk users as owners to Teams sites significantly improves efficiency and reduces the risk of errors. By following the steps outlined in this blog post, you can seamlessly add owners to multiple Teams sites, saving valuable time and ensuring smooth collaboration within your organization.
Remember, PowerShell provides numerous possibilities for customization and automation. Feel free to explore further and adapt the script according to your specific needs.
We hope this blog post has provided you with a practical solution for managing Teams site ownership efficiently. Embrace the power of automation and enjoy a streamlined collaboration experience with Microsoft Teams!
Don’t hesitate to reach out if you have any questions or need further assistance.
Happy collaborating with Microsoft Teams!
Discover more from Blogs | Saied Taki
Subscribe to get the latest posts sent to your email.

