PowerShell スクリプトを使用して情報バリア モードを変更する

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

このスクリプトでは、Exchange Online PowerShell モジュールにある Get-UnifiedGroup コマンドレットを使用してモードを更新します。 PowerShell を使用した Teams の管理の詳細については、「 Teams PowerShell の概要」を参照してください。

前提条件

このスクリプトを実行する前に、次の前提条件があることを確認してください。

重要

Microsoft では、アクセス許可が可能な限りで少ないロールを使用することをお勧めします。 グローバル管理者ロールを持つユーザーの数を最小限に抑えることで、組織のセキュリティを向上させることができます。 Microsoft Purview のロールとアクセス許可の詳細をご覧ください。

スクリプトを実行する

既存のすべての Teams 接続グループの IB モードを更新するには、次の手順を実行します。

  1. Exchange Online PowerShell に接続します。

    Connect-ExchangeOnline
    
  2. 次のスクリプトをコピーして実行します。 このスクリプトでは、Teams に接続されているすべてのグループが オープン モードで識別され、 暗黙的 モードに更新されます。

  3. スクリプトが完了したら、正常に更新されたグループの数の出力を確認します。 グループの更新に失敗した場合は、現在のディレクトリで生成されたBackfillFailedTeams.csv ファイルをチェックして詳細を確認し、失敗したグループを再試行してください。

サンプル スクリプト

<#
.SYNOPSIS
This script updates the IB 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."))
}

次の手順