web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to add individuall...
Power Automate
Answered

How to add individually add multiple email addresses in array to a security group

(0) ShareShare
ReportReport
Posted on by

Hello all!

 

I have a flow that currently has an array named 'Joined Active Users' ~ this is how I created it:

 

jharville_0-1704256157737.png

jharville_1-1704256245371.png

 

The contents of the array currently look like: 

 

jharville_2-1704256531651.png

 

How would I add each of those emails to a security group? I figured I'd have to use the 'Apply to Each' with an 'Add User to Group' action inside (Co-Pilot confirmed this decision), but I'm having issues every time I test the flow.

 

This is what's currently inside the 'Apply to Each 1' and 'Add User to Group' sections:

 

jharville_3-1704256724010.png

 

 

jharville_0-1704257437122.png

 

 

Any help at all would be greatly appreciated! Best of wishes and happy new year!

 

 

 

Categories:
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @jharville 

    According to your screenshot , your action "add user to group" return error code "Bad Request".

    As test in my side , you need to pass the User Id in this action instead of the User Email.

    vyueyunmsft_0-1704262128742.png

    So you can add a Get user profile (V2) action before your "add user to group" action to get the Id of the user.

    vyueyunmsft_1-1704262359098.png

    This is the result for this flow:

    vyueyunmsft_2-1704262388586.png

    And for this action if current user have existed in this group, it will return an error code and it do not influence the flow, you can just ignore it .

     

     

    If I misunderstand what you mean, you can describe your needs and your expected outcomes in detail so that we can better help you. If this reply can help you , you can click mark this reply as solution, thanks in advance!


    Best Regards,

    Yueyun Zhang

     

  • jharville Profile Picture
    on at

    @v-yueyun-msft 

     

    Hello and thank you so much for your response. Earlier in my flow, I already did use the 'Get User Profile (V2)' ..

     

    jharville_0-1704267593841.png

     

    but after that I use the 2 opposite below 'append to variable' functions to split the results into:

    1) users that are in our tenant

    2) users that are *not* in our tenant

     

    jharville_1-1704267712127.png

    jharville_2-1704267755833.png

    --------------------

    jharville_3-1704268054025.png

    jharville_4-1704268090405.png

     

     

     

    My question would be how would I reference the 'Outputs' of only the users that are found in our tenant (which is all of the email addresses in the Joined_Active_Users array ?

     

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @jharville 

    As my above reply , we can suppose the compose action is your Joined_Active_Users array:

    vyueyunmsft_0-1704268645053.png

     

    vyueyunmsft_0-1704268195022.png

    As we need to use the Id field return by the "Get user profile V2" action instead of using the user Email in your Joined_Active_Users array.

    So you need to Apply to each your Email array in your side .

    vyueyunmsft_0-1704270045773.png

     

     

     

    If I misunderstand what you mean, you can describe your needs and your expected outcomes in detail so that we can better help you. If this reply can help you , you can click mark this reply as solution, thanks in advance!


    Best Regards,

    Yueyun Zhang

     

     

     

     

     

  • jharville Profile Picture
    on at

     

    Hello @v-yueyun-msft 

     

    So if I understand correctly, I can keep the previous 'Search for Users (V2)' that I used earlier on in the flow ... but later on in my flow I have to add an 'Apply to Each' inside of a 'Condition' .. and inside of that 'Apply to Each' is where I place the 'Get User Profile (V2)' ? 

     

    I tried doing that but I don't see an option for 'Current Item' to put inside the "UPN" of 'Get User Profile' 

     

    jharville_0-1704301296363.png

     

    ---------

    jharville_1-1704301438293.png

     

    Since I didn't see the option for 'Current Item' to put inside of 'Get User Profile (V2)' .. I just put the following for testing purposes:

    jharville_1-1704302593530.png

     

    ... and the following error came up:

    jharville_0-1704302503994.png

     

  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @jharville 

    You can just Apply to each your "varActiveUsers" variable and you do not need to join them.

    vyueyunmsft_1-1704337372962.png

    Apply to each action we need to pass a array instead of string type.

    And if you do not have "current item" in dynamic content , you can just use the Expression here:

    items('Apply_to_each')

    vyueyunmsft_2-1704337446428.png

    The Apply_to_each is the action Name in my side. The space need to replace by '_'.

     

    Best Regards,

    Yueyun Zhang

     

     

     

  • jharville Profile Picture
    on at

    Works perfectly as intended now, thank you so much for your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 275 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 235

#3
David_MA Profile Picture

David_MA 178 Super User 2026 Season 2

Last 30 days Overall leaderboard