Thursday, September 21, 2023

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


$settingsObjectID = (Get-AzureADDirectorySetting | Where-object -Property Displayname -Value "Group.Unified" -EQ).id
    $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

  $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.

Have a good week everybody.

Mark – The Cloud Geezer

Mark Rochester
Mark Rochester
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

Microsoft 365 Workload Activity Report

Well that's a pretty boring title and an even more boring name for a script. However the output is definitely not boring as it...

Migrate GoDaddy M365 Email to a Full M365 Tenant

We do come across this scenario whereby the GoDaddy M365 Email option has been selected when you register your domain and you end up...

Easily Create MailUser Objects

When it comes to the setup and configuration of the Microsoft 365 Cross-Tenant Migration Tools, the first part is obviously the initial configuration and...

Stay Connected

- Advertisement -

Latest Articles