How to restrict Group and Teams Creation with MSGraph

 You're right! Since AzureAD and MSOnline modules are deprecated, you need to use the Microsoft Graph PowerShell SDK to retrieve the group ID.


Solution Using Microsoft Graph PowerShell

You must have a M365 group created first and define the membership : Allowed Group Creators.

1. Install and Connect to Microsoft Graph PowerShell

If you haven't installed it yet, run:

Install-Module Microsoft.Graph -Scope CurrentUser

Then, sign in with an Admin account:

Connect-MgGraph -Scopes "Group.Read.All", "Directory.ReadWrite.All"

If prompted, grant admin consent for the required permissions.


2. Get the Security Group ID

Since Get-AzureADGroup no longer works, use this instead:

Get-MgGroup -Filter "displayName eq 'Allowed Group Creators'"

Copy the Id from the output (this is the Object ID needed for the restriction).


3. Apply Group Creation Restriction

Run the following PowerShell commands to modify the Microsoft 365 Group Creation Policy:

$GroupID = "<Paste-the-Group-Id-Here>", like 95e69920-xyz-4960-8899-ee1f12345

# Retrieve existing directory settings
$Settings = Get-MgBetaDirectorySetting | Where-Object {$_.DisplayName -eq "Group.Unified"}

# If no settings exist, create one
if (-not $Settings) {
    $Template = Get-MgBetaDirectorySettingTemplate | Where-Object {$_.DisplayName -eq "Group.Unified"}
    $Settings = New-MgBetaDirectorySetting -TemplateId $Template.Id
}

# Update settings to restrict group creation
Update-MgBetaDirectorySetting -DirectorySettingId $Settings.Id -Values @{'EnableGroupCreation'='false'; 'GroupCreationAllowedGroupId'=$GroupID}

4. Verify the Restriction

Now, test:
Admins & the specific user → Should be able to create Teams & Groups.
Other users → Should be blocked from creating Groups/Teams.

This method ensures that only the designated users can create Teams, Planner workspaces, and SharePoint Team sites.

Or simply use the Admin Center in Entra AD:




Comments

Popular posts from this blog

How to hide users from GAL if they are AD Connect synchronized

Exchange x500 address x500:/o=ExchangeLabs

MFA with Guest Access and different tenants settings