次の方法で共有


PowerShell スクリプトを使用した情報バリア モードの変更

この PowerShell スクリプトを使用して、テナント内のすべての Teams に接続されているグループの情報バリア (IB) モードを更新します。 情報バリアをデプロイした後、これらのグループのモードを更新する必要があります。 IB を有効にする前にプロビジョニングされたグループには、 オープン モードが割り当てられます。 オープン モードでは、該当する IB ポリシーはありません。 IB を有効にすると、 作成 した新しいグループの既定のモードになります。 ただし、既存のグループは き続きオープン モードの構成を維持します。 これらの既存のグループを 暗黙的 モードに変更するには、このスクリプトを実行します。

このスクリプトでは、Exchange Online PowerShell モジュールにある Get-UnifiedGroup コマンドレットを使用してモードを更新します。 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.")) 
}