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