Skip to content

Instantly share code, notes, and snippets.

@andreagx
Last active September 3, 2020 09:14
Show Gist options
  • Select an option

  • Save andreagx/fc9b9ea2628f67bad8f6b435608a03a9 to your computer and use it in GitHub Desktop.

Select an option

Save andreagx/fc9b9ea2628f67bad8f6b435608a03a9 to your computer and use it in GitHub Desktop.
DisableTeamCreation.ps1
#AzureAD preview module needed
#Before install AzureADPreview module, uninstall AzureAD Module: Uninstall-Module -Name AzureAD -Force
$groupname = "TEAMS-TeamCreation"
Connect-AzureAD
Get-AzureADGroup -SearchString $groupname
$Template = Get-AzureADDirectorySettingTemplate | where {$_.DisplayName -eq 'Group.Unified'}
$Setting = $Template.CreateDirectorySetting()
New-AzureADDirectorySetting -DirectorySetting $Setting
$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
(Get-AzureADDirectorySetting).Values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment