When enabling the Teams license in Office 365, every member within the organisation can create Teams. To prevent uncontrolled growth of Teams, it is a best practice to disable the creation of Teams and put in place a provisioning engine instead.

After the script has run, the creation of Office 365 Groups and Teams will be disabled.

Here you can find the Powershell script to disable Team creation.

Note: if you have the AzureAD module installed, you need to uninstall it first.
Also make sure you have the AzureADPreview module installed.

UnInstall-Module AzureAD
Install-Module -Name AzureADPreview -RequiredVersion -AllowClobber
Import-Module AzureADPreview


Get-AzureADGroup -SearchString "Name of your security group"

$Template = Get-AzureADDirectorySettingTemplate | where {$_.DisplayName -eq 'Group.Unified'}

$Setting = $Template.CreateDirectorySetting()

New-AzureADDirectorySetting -DirectorySetting $Setting

If you get an error like this, you can skip to the next step.

$Setting = Get-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id

$Setting["EnableGroupCreation"] = $False

$Setting["GroupCreationAllowedGroupId"] = (Get-AzureADGroup -SearchString "Name of your security group").objectid

Set-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id -DirectorySetting $Setting

Only members of the “Name of your security group” security group can create groups. No one else can, as indicated by EnableGroupCreation = False.