Saturday, July 4, 2026

Stop Microsoft Teams Sprawl

Anybody that has come into an organization and looked at the Teams Admin Center, had a heart attack because there are so many Teams created by pretty much everybody in the organization will be wishing that this little setting had been changed right at the start.

Even if you have Teams Sprawl now, you can run this to stop it getting any worse.

Basically it just turns off the ability for every man and his dog from being able to create new Teams. It limits the creation to a single Azure Security Group.

Here is the video showing it all in action, but as I mentioned in the video, the script is pasted below so you have it.

Remember too, that you need to use the AzureADPreview module and not the AzureAD version. Most of us Admins would always be using this one anyway because it has all the latest cmdlets, plus the ones published in the AzureAD version.

Here you go, it’s pretty small but invaluable.

$GroupName = "Teams Creators"
$AllowGroupCreation = $False

#Connect-AzureAD

$settingsObjectID = (Get-AzureADDirectorySetting | Where-object -Property Displayname -Value "Group.Unified" -EQ).id
if(!$settingsObjectID)
{
    $template = Get-AzureADDirectorySettingTemplate | Where-object {$_.displayname -eq "group.unified"}
    $settingsCopy = $template.CreateDirectorySetting()
    New-AzureADDirectorySetting -DirectorySetting $settingsCopy
    $settingsObjectID = (Get-AzureADDirectorySetting | Where-object -Property Displayname -Value "Group.Unified" -EQ).id
}

$settingsCopy = Get-AzureADDirectorySetting -Id $settingsObjectID
$settingsCopy["EnableGroupCreation"] = $AllowGroupCreation

if($GroupName)
{
  $settingsCopy["GroupCreationAllowedGroupId"] = (Get-AzureADGroup -SearchString $GroupName).objectid
} else {
$settingsCopy["GroupCreationAllowedGroupId"] = $GroupName
}
Set-AzureADDirectorySetting -Id $settingsObjectID -DirectorySetting $settingsCopy

(Get-AzureADDirectorySetting -Id $settingsObjectID).Values

Thanks for helping me out by Subscribing to the YouTube channel here.

https://youtube.com/thecloudgeezer?sub_confirmation=1

Have a good week everybody.

Mark – The Cloud Geezer

Mark Rochester
Mark Rochesterhttps://thecloudgeezer.com
Mark currently works in the cloud space assisting large companies to migrate from either on premises to the cloud, or cloud to cloud. His experience with Enterprise migrations spans more than 25 years which basically makes him old. However, with all the oldness creeping up he still finds technology massively exciting. Please reach out for a chat anytime you would like. :-)

Related Articles

OneDrive Sharing Report – June 2026

Take Control of OneDrive Sharing Across Your Entire Microsoft 365 Tenant Let's be honest — Microsoft's built-in sharing reports are pretty underwhelming. They show you...

SharePoint Discovery Tool

Know exactly who has access to what across your entire SharePoint Online environment. Managing SharePoint permissions at scale is one of the most time-consuming and...

Microsoft 365 Discovery Report

How long does a full Microsoft 365 tenant assessment take you? For me, it used to be half a day. Clicking through Exchange admin, SharePoint...

Stay Connected

88FansLike
36,999FollowersFollow
70,704SubscribersSubscribe
- Advertisement -

Latest Articles