Saturday, April 20, 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

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

Microsoft 365 Discovery Report

If you are working with a Microsoft 365 tenant, whether it is for your own or for a client, it is often necessary to...

Batches Paused in ‘Needs Approval’ Status

When you are using the native Microsoft tools to migrate from Google Workspace (Gmail) into Microsoft 365 the tool works very well. It does...

Stay Connected

88FansLike
36,999FollowersFollow
32,381SubscribersSubscribe
- Advertisement -

Latest Articles