Skip to content

Instantly share code, notes, and snippets.

@win2000b
Created January 6, 2026 17:24
Show Gist options
  • Select an option

  • Save win2000b/934d068ab7d3bd238233c4d03b70fbb5 to your computer and use it in GitHub Desktop.

Select an option

Save win2000b/934d068ab7d3bd238233c4d03b70fbb5 to your computer and use it in GitHub Desktop.
Entra ID - Create New Group with Members of Existing
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Group.ReadWrite.All"
# Add in Entra Group ID of the Existing Group below
$sourceGroupId = "<ExistingGroupObjectId>"
# Fetch ALL members
$members = Get-MgGroupMember -GroupId $sourceGroupId -All
# Create the new Group
$newGroup = New-MgGroup -DisplayName "New Group Name" -MailEnabled:$false -MailNickname "newgroup" -SecurityEnabled:$true
# Add members to the new group
foreach ($member in $members) {
New-MgGroupMember -GroupId $newGroup.Id -DirectoryObjectId $member.Id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment