How to disable group nesting in Microsoft Entra ID

How to disable group nesting in Microsoft Entra ID
How to disable group nesting in Microsoft Entra ID

Nested security groups give admins more flexibility with their access assignments in Microsoft Entra, but they can also make it difficult to see how a user received access and doesn’t support many services anyway. Microsoft Entra now exposes a disableNesting property through the Microsoft Graph beta endpoint. Setting this property when you create a group prevents another group from being added as a member.

This article shows you how to create a security group with nesting disabled by calling Microsoft Graph from PowerShell, then test the restriction by attempting to add another group.

Why disable group nesting?

Group nesting allows you to add one security group as a member of another. This can be useful, but it also introduces indirect membership. A user might inherit access through several layers of groups, making access reviews and troubleshooting harder.

Disabling nesting is useful for groups that protect sensitive applications or resources where you want every member to be added directly. It creates a clearer membership boundary and reduces the chance that an administrator grants access to many users by adding the wrong group. It does not replace regular access reviews, but it removes one route through which unexpected membership can appear.

Create the group with PowerShell

You need the Microsoft.Graph.Authentication module and an account permitted to create groups. The least-privileged delegated permission for creating a group is Group.ReadWrite.All, then Group-NestingSupport.ReadWrite.All can be used if you just need to update the disableNesting property of an existing group.

First, install the authentication module if you do not already have it, then connect to Microsoft Graph:

Install-Module Microsoft.Graph.Authentication -Scope CurrentUser
Connect-MgGraph -Scopes 'Group.ReadWrite.All'
Next, build the request body. The combination of mailEnabled set to $false and securityEnabled set to $true creates a security group. Change the display name and mail nickname to suit your tenant. Importantly, the disableNesting property set to $true prevents groups from being added as member of this group. By default, this property is enabled and as of the time of writing this, can only be set during the creation of a new group.
$body = @{
    displayName     = 'NestingTst3'
    mailNickname    = 'NestingTst3'
    mailEnabled     = $false
    securityEnabled = $true
    disableNesting  = $true
}

$uri = 'https://graph.microsoft.com/beta/groups'
$group = Invoke-MgGraphRequest -Method POST -Uri $uri -Body $body

Of-course, the above group has been created using the minimum information required. For more detail on creating groups with PowerShell, see my related articles here.

Test the nesting restriction

Once the group has been created, whether you trying to add a group as a member via the Microsoft Entra UX or Microsoft Graph API, you will be greeted with an error message. Right now, that message is generic, however I assume it will be updating to something more meaningful in the future.

Failed to add a group member with group nesting disabled
Failed to add a group member with group nesting disabled

The disableNesting property

Because this feature is new, and at the time of writing this, no information exists on Microsoft Learn about this capability outside of a single mention of the graph API permission, there isn’t much more official information I can share about it. I did test trying to viewing the value of this property on a group via the Microsoft Graph API, however, it doesn’t return with a basic GET request to the BETA endpoint for a specific group (or any/all groups), it only shows if you use ?$select=disableNesting on a group with the setting already enabled.

Daniel Bradley

Daniel Bradley is a UK-based technical architect and Microsoft MVP in Security. He specialises in Microsoft Entra, Intune, and Microsoft Graph PowerShell and is the author of Microsoft Graph PowerShell for Administrators. He writes and edits Our Cloud Network using experience gained from working with Microsoft cloud environments.

This Post Has 2 Comments

Leave a Reply