Created
January 6, 2026 17:24
-
-
Save win2000b/934d068ab7d3bd238233c4d03b70fbb5 to your computer and use it in GitHub Desktop.
Entra ID - Create New Group with Members of Existing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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