Thursday, December 19, 2024

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

Google GSuite Discovery Tool

When it comes time to perform a migration from Google GSuite to Microsoft 365 the first thing we always ask is - "How much...

Microsoft 365 Discovery Report

Overview The Microsoft 365 Discovery Report is a collection of outputs from the various workloads inside a Microsoft 365 tenant, all consolidated into a single...

Migrate Microsoft 365 Mailboxes to Google Workspace

This is not a very common subject to talk about as most of the migrations that get performed are people moving into the Microsoft...

Stay Connected

88FansLike
36,999FollowersFollow
50,237SubscribersSubscribe
- Advertisement -

Latest Articles