How to Add Members to Microsoft Teams using Power Automate?

I was working recently with Microsoft Teams, where I needed to add members to a particular team in Microsoft Teams automatically using Power Automate.

I will explain how to add a member to a specific team in Microsoft Teams using Power Automate from a SharePoint list. Also, I will show you how to add bulk members to the team site in Microsoft Teams from an Excel spreadsheet using Power Automate.

Then, I will give another example of adding an external member to a team in Microsoft Teams with Power Automate.

Add Members to Microsoft Teams using Power Automate

Microsoft Teams is a part of Microsoft 365 Group. Adding members to the Microsoft Team allows the user to have permission to create a channel, private chat, messages, share a channel, create meetings or access schedules, invite other guests, create teams, etc.

The user should be the Team owner to add members to the Microsoft Teams.

1. Add From a SharePoint list

Now, let’s discuss how to automatically add a member to a particular team in Microsoft Teams from a SharePoint list using Power Automate.

Example:

For this, I have created a SharePoint list named Request Access Form, which comprises the below columns presented in the table:

Column NameDataType
Team Name [Title column]Single line of text
MemberPerson or Group column
Power Automate add a member to specific team in Microsoft Teams

Whenever a user enters an item into the SharePoint list, the flow will trigger, and it will add the member to the Team the user has provided.

Follow the below steps to create the flow.

1. Open the Power Automate home page in your browser, click + Create -> Select the Automated cloud flow -> Provide the flow name, and choose the trigger’s flow (When a new item is created) -> Click Create button.

Set the below details:

  • Site Address: Select a specific SharePoint site from the drop-down.
  • List Name: Choose a specific SharePoint list from the drop-down menu.
How to use Power Automate to add a member to team in Microsoft Teams

2. After that, add List teams flow action to get all the teams in the Microsoft Teams.

Here, I wanted to retrieve the Team ID for the particular team name that already existed in Microsoft Teams.

To get that, I will add a Condition control action to match the below condition.

ValueOperatorValue
Team Name [From list teams]is equal toTitle [SharePoint list]

3. Take Condition control flow action, and provide condition expression like the below:

@{items('For_each')?['displayName']} is equal to @{items('Apply_to_each')?['Title']}

For each loop will be added automatically when we take the condition expression.

Add a member to specific team in Microsoft Teams with Power Automate

4. Under, True condition, add Get user profile(v2) flow action to retrieve member details like email address. Provide the user details:

  • User(UPN): Select the field -> Take Member Email from the dynamic content.
See also  SharePoint Online document library [Complete guide]

Then, Apply to each will be added to the True condition as shown below:

How to add a member to the particular team in Microsoft Teams using Power Automate

5. After that, add an Add member to a team flow action. Configure the required details below:

  • A user principal name or AAD ID to add to a: Select User Principal Name from the dynamic content.
  • Team: Select Team Id from the dynamic content.
Adding a member to specific team in Microsoft Teams with Power Automate

6. Now, it’s time to save the flow. Click on the Save button. Then, select Test. Run the flow Manually. Click on Run flow.

7. Below is the image of the Microsoft Team site having only one member.

Add a member from SharePoint list to Microsoft teams team using Power Automate

8. Go to the SharePoint list and create an item, as shown below.

Adding membser to specific team in Microsoft Teams using Power Automate

9. When the flow runs successfully, If there is no existing user, it will add a member to the specific team in Microsoft Teams.

After adding a member to the team, you can see from the below image:

Power Automate how to add a member to Microsoft Teams

This is how to automatically add a member to a single team in MS Teams with Power Automate.

2. Add From An Excel File

So, now let me show you how to add a list of members to a single team in Microsoft Teams using Power Automate from Excel data.

We need to create an Excel table with the Name and Email address and Team Name as shown below. After that, format the Excel list as a table and save it. The data will be saved in OneDrive.

Power Automate add Members to specific team of Microsoft Teams using Excel

I need to add the users in the Excel sheet to Microsoft Teams using Power Automate.

Image showing added members in Microsoft Teams:

Bulk add members to Microsoft Teams Using Power Automate

To achieve this, go through the below steps:

1. Navigate to https://make.powerautomate.com in your browser to open the Power Automate Home page -> click + Create -> Select the Instant cloud flow -> Provide the flow name, and choose the trigger’s flow (Manually trigger a flow) -> Click the Create button.

2. Then, take List rows present in a table flow action to get the values in the Excel sheet. Add the following details:

  • Location: Select the location of the Excel data where it is saved from the drop-down.
  • Document Library: Choose the document library from the drop-down menu.
  • File: Select the file name that you have saved.
  • Table: Select a table.
How to  add multiple members to Microsoft Teams using Power Automate

3. To check if the users are present in the organization, add the Search for the user (v2) flow action.

  • Search term: Take Email Address from the dynamic content of Excel.
Power Automate how to add multiple members to Microsoft Teams

4. Then, take Add member to a team flow action to add the retrieved members from the active directory to the team in Microsoft Teams.

  • Team: Select the existing Microsoft Team from the drop-down.
  • A user principal name or AAD ID to add to a: Select User Principal Name from the dynamic content.
How to Add list of members to Microsoft Teams Power Automate

Once the flow is ready, save and test it manually.

See also  How to Apply Conditional Formatting in Power BI Area Chart?

5. Then, you can see the result of the Power Automate flow by adding members to the particular team in Microsoft Teams, as shown in the figure below:

How to add multiple members in Microsoft Teams with Power Automate

This is how to add bulk members to a team of Microsoft Teams from Excel using Power Automate.

Add External Members to a team in Microsoft Teams using Power Automate

You can also add external members to a team in Microsoft Teams using Power Automate.

Here, I have created a Microsoft Form with the below columns:

  • External User Name
  • Email Address
Power Automate add external user to Microsoft Teams

In that form, I have enabled the Microsoft Forms settings to allow Anyone can respond, so that members outside the organization can submit the response without signing into a Microsoft account.

How to add External member to Microsoft Teams in Power Automate

Note:

One should have the Site owner’s permission to add the external user to the Microsoft Team site.

As well as, you should need to set the sharing settings to Anyone for that particular site at the site level.

  • Go to the SharePoint admin center with https://tenant name -admin.sharepoint.com
  • Expand Sites -> Select Active sites.
  • Select a Specific SharePoint site from the Active sites page.
  • Click Settings -> Choose Anyone in External file sharing.
Add External Members to a team in Microsoft Teams using Power Automate

Now, let us see how to create the flow using Power Automate.

1. Open the Power Automate Home page -> Click +Create -> Select Automated cloud flow -> Give a flow name and choose a trigger [When a new response is submitted] -> Click the Create button.

Adding Externa luser to Microsoft Teams in Power Automate

2. Add a new step taking the ‘Get response details‘ flow action to retrieve the responses submitted in the Microsoft Forms.

Give the below details:

  • Form Id: Select the Microsoft Form that you have created.
  • Response ID: Take the Response Id from the dynamic content.
How to add outside members to Microsoft Teams

3. Then, add a Compose flow action to provide the replace() expression. Place the below expression in the Inputs section.

Here, I was replacing @ in the Email Address with ‘_’ to get the format of the external user.

See also  Power Automate Rename File | Power Automate Rename SharePoint File

Inputs: Click Expression -> Give the below code.

replace(outputs('Get_response_details')?['body/re9456f4f80af4809bfb2f7334598eb70'],'@','_')

After that, Click OK.

How to add outside members to Microsoft Teams with Power Automate

4. Next to that, add the Create user flow action from the Microsoft Entra connector.

Set all the following details in it.

Important

You need to have Global Admin access to create a external user in the Azure active directory.
  • Account Enabled: Select Yes from the drop-down.
  • Display Name: Take the External User Name column from the dynamic content.
  • Mail Nickname: Enter a nickname for a user.
  • Password: Set a strong password.
  • User Principal Name: Take outputs of compose along with the code below.
outputs('Compose')#EXT#@szg52.onmicrosoft.com
Power Automate add outside members to Microsoft Teams

5. Add a Delay flow action to stop the flow for one minute because it will take a few seconds to create the user.

Set the delay action:

  • Count: Take the count as 1 manually.
  • Unit: Select ‘Minute‘ from the drop-down.

I included this mainly because the flow is running into error, but it creates and adds users to Microsoft Teams.

Automatically add external users to Teams from Microsoft Teams

6. In the final step, take “Add member to a team” flow action and set the properties.

  • Team: Select a Microsoft Team to which you need to add an external member.
  • A user principal name or AAD ID to add to a: Take Id column from the Create user of dynamic content.
How to Automatically Add external Member to MS Teams' With Power Automate

7. When the flow is created Save and run the manually. Click on Save -> Select Manually radio button in the test flow window -> Select Runflow.

8. Now, submit a response in the Microsoft Form [Interior Design Team] with Name and Email Address as shown below:

Power Automate add external user into Microsoft Team site

9. If no existing user exists, the flow runs successfully, creates a user in the Azure Active directory, and adds that particular user to the specific team of Microsoft Teams.

Power Automate add a external member to Microsoft Teams
Adding outside member to Microsoft Teams using Power Automate

10. If the user is already there in the Azure active directory, Create user fails, and the flow gives an error as shown below:

Adding external user to the Microsoft Teams using Power Automate

This is how to add an outside member to the team site of Microsoft Teams using Power Automate with the help of Microsft Forms.

Conclusion

In this tutorial, I have explained how to add a member to a team in Microsoft Teams using Power Automate.

You may also like:

>