阻止用戶在 Microsoft 365 (Teams/Outlook) 中創建新組

Jacki

默認情況下,Azure 租戶中的任何用戶都可以創建 Microsoft 365 組。當用戶創建新的 Microsoft 365 組時,會自動創建其他資源:Teams 組、Exchange Online 中的共享郵箱和日曆、SharePoint Online 中的網站和文檔庫、Yammer 組等。

本文介紹了阻止普通(非管理員)用戶在 Microsoft 365(Teams/Outlook 等)中創建新組的方法。您需要做的第一件事是限制在 AzureAD 中創建統一組的權限。請注意,當前無法僅阻止用戶創建 Teams 組。禁止創建新組將適用於所有 Microsoft 365 服務,包括 SharePoint、Exchange、OneNote、Yammer、Planner、PowerBI 等。

在此屏幕截圖中,您可以看到用戶可以從 Teams 界面創建新組(團隊)或加入現有組。

在這種情況下,我們將阻止普通用戶創建新的 Microsoft 365 組。完成後,我們將使用GroupCreationAllowedGroupId參數僅允許管理員創建新組。

在計算機上安裝 AzureADPreview 和 AzureAD PowerShell 模塊(Set-AzureADDirectorySetting我們需要的 cmdlet 目前僅在 AzureADPreview 中可用)。

Install-Module AzureAD
Install-module AzureADPreview -AllowClobber –Force

連接到您的 Azure 租戶:

AzureADPreviewConnect-AzureAD

推薦閱讀:禁用 Microsoft 365 組的歡迎消息

現在讓我們創建一組可以創建統一組的 Azure 管理員組:

New-AzureADGroup -MailNickName "TeamsAdmins" -DisplayName "TeamsAdmins" -MailEnabled $false -SecurityEnabled $true -Description "Members can create new Unified Groups (including Teams)"

並將 Teams 管理員帳戶添加到組中:

$Group = "TeamsAdmins"
$User = "[email protected]"
$GroupObj = Get-AzureADGroup -SearchString $Group
$UserObj = Get-AzureADUser -ObjectId $User
Add-AzureADGroupMember -ObjectId $GroupObj.ObjectId -RefObjectId $UserObj.ObjectId

讓我們看看當前創建 Teams 組的權限:

$settingsObjectID = (Get-AzureADDirectorySetting | Where-object -Property Displayname -Value "Group.Unified" -EQ).id
(Get-AzureADDirectorySetting -Id $settingsObjectID).Values

這裡,EnableGroupCreation = trueGroupCreationAllowedGroupID = not set,這意味著用戶可以創建 Teams (Microsoft 365) 組。

如果 Get-AzureADDirectorySetting cmdlet 返回空數組 (Get-AzureADDirectorySetting : Cannot bind argument to parameter 'Id' because it is null),您首先需要按照指南中的說明配置設置https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/groups-settings-cmdlet(步驟 1 至 6):

$TemplateId = (Get-AzureADDirectorySettingTemplate | where { $_.DisplayName -eq "Group.Unified" }).Id
$Template = Get-AzureADDirectorySettingTemplate | where -Property Id -Value $TemplateId –EQ
$Setting = $Template.CreateDirectorySetting()
$Setting["EnableMIPLabels"] = "True"
New-AzureADDirectorySetting -DirectorySetting $Setting

現在,我們只允許在 Microsoft 365 中為 TeamsAdmins 組創建新組:

$Setting = Get-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id
$Setting["EnableGroupCreation"] = $False
$Setting["GroupCreationAllowedGroupId"] = (Get-AzureADGroup -SearchString "TeamsAdmins").objectid
Set-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id -DirectorySetting $Setting

並檢查組創建權限是否已更改:

(Get-AzureADDirectorySetting).Values

如果要將配置重置為默認值並允許所有用戶創建 Microsoft 365 組,請運行以下命令:

$Setting = Get-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id
$Setting["EnableGroupCreation"] = $True
$Setting["GroupCreationAllowedGroupId"] = $null
Set-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id -DirectorySetting $Setting

現在以普通(非管理員)用戶身份運行 Teams,以檢查創建新 Teams 組的選項是否不再可用。用戶現在只能連接到現有的 Teams 組。

若要允許用戶在 Microsoft 365(包括 Teams)中創建組,您需要將用戶帳戶添加到 TeamsAdmins 組。