Copy users from one Azure AD group to another

Juan (Johnny) Rivera 21 Reputation points
2022-12-05T19:29:54.28+00:00

I'm needing to copy users from one Azure ad group to another, twist being that the users needing to be copied all have a specific email ( ex. @*.com ) and the group has multiple different email address. I'm pretty new to Powershell and was looking for a good solution for this task. Thanks in advanced for any advice.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    2022-12-08T00:32:45.45+00:00

    Hi @Juan (Johnny) Rivera ,

    You would need to query the members of the group using Get-AzureADGroupMember and run a ForEach loop to add the members to the new group (using Add-AzureADGroupMember).

    Example script:

    (Get-AzureADGroupMember -ObjectId xxxx -All $true) | ForEach-Object {Add-AzureADGroupMember -ObjectId xxxx -RefObjectId $_.ObjectID}  
    

    Satheshwaran Manoharan has provided a great step-by-step blog post here that achieves this and walks through each step.

    To update the OtherMails property you would need to use Set-AzureAdUser and most likely import all of the user info into a CSV as described here.

    Let me know if this helps and if you have further questions!

    Additional example from Stack Overflow:

    -

    If the information helped you, please Accept the answer. This will help us and other community members as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.