使用此 PowerShell 腳本來更新租使用者中所有 Teams 連線群組的資訊屏障 (IB) 模式。 您必須在部署資訊屏障之後更新這些群組的模式。 在啟用 IB 之前建立的群組會獲指派 [開啟 ] 模式。 在 開放 模式下,沒有任何適用的 IB 政策。 啟用 IB 之後, 隱含會 成為您建立的任何新群組的預設模式。 不過,現有群組仍會保留 開放 模式設定。 執行此指令碼,將這些現有群組變更為 隱含 模式。
在此腳本中,您會使用 Exchange Online PowerShell 模組中的 Get-UnifiedGroup Cmdlet 來更新模式。 若要深入瞭解如何使用 PowerShell 管理 Teams,請參閱 Teams PowerShell 概觀。
指令碼範例
重要事項
Microsoft 建議您使用權限最少的角色。 將具有全域系統管理員角色的使用者數目降到最低,有助於改善組織的安全性。 深入瞭解 Microsoft Purview 角色和許可權。
若要執行此腳本,請使用具有租使用者全域系統管理員角色的公司或學校帳戶。
<#
.SYNOPSIS
This script updates the information barrier mode for all Teams-connected groups in your tenant at the same time.
.DESCRIPTION
Use this script to update the info barrier mode from open to implicit across the groups in your tenant.
#>
$teams = Get-UnifiedGroup -Filter {ResourceProvisioningOptions -eq "Team"} -ResultSize Unlimited
Write-Output ([string]::Format("Number of Teams = {0}", @($teams).Length))
$teamsToUpdate = New-Object System.Collections.ArrayList
foreach($team in $teams)
{
if ($team.InformationBarrierMode -eq "Open")
{
$teamsToUpdate.Add($team.ExternalDirectoryObjectId) | out-null
}
}
Write-Output ([string]::Format("Number of Teams to be backfilled = {0}", @($teamsToUpdate).Length))
$outfile = "BackfillFailedTeams.csv"
if (!(Test-Path "$outfile"))
{
$newcsv = {} | Select "ExternalDirectoryObjectId", "ExceptionDetails" | Export-Csv $outfile -NoTypeInformation
}
else
{
$dateTime = Get-Date
$newEntry = "{0},{1}" -f "New session started", $dateTime
$newEntry | add-content $outfile
}
$SuccessfullyBackfilledGroup = 0
for($i = 0; $i -lt @($teamsToUpdate).Length; $i++)
{
Invoke-Command { Set-UnifiedGroup $teamsToUpdate[$i] -InformationBarrierMode "Implicit" } -ErrorVariable ErrorOutput
if ($ErrorOutput)
{
# saving the errors in a csv file
$errorBody = $ErrorOutput[0].ToString() -replace "`n"," " -replace "`r"," " -replace ",", " "
$newEntry = "{0},{1}" -f $teamsToUpdate[$i].ToString(), '"' + $errorBody + '"'
$newEntry | add-content $outfile
}
else
{
$SuccessfullyBackfilledGroup++
}
if (($i+1) % 100 -eq 0)
{
# print the number of teams backfilled after the batch of 100 updates
Write-Output ([string]::Format("Number of Teams processed= {0}", $i+1))
}
}
Write-Output ([string]::Format("Backfill completed. Groups backfilled: {0}, Groups failed to backfill: {1}", $SuccessfullyBackfilledGroup, @($teamsToUpdate).Length - $SuccessfullyBackfilledGroup))
if (!($SuccessfullyBackfilledGroup -eq @($teamsToUpdate).Length))
{
Write-Output ([string]::Format("Check the failed teams in BackfillFailedTeams.csv, retry to backfill the failed teams."))
}