Share via


Ändern von Informationsbarrierenmodi mit einem PowerShell-Skript

Verwenden Sie dieses PowerShell-Skript, um den IB-Modus (Information Barrieren) für alle mit Teams verbundenen Gruppen in Ihrem Mandanten zu aktualisieren. Sie müssen den Modus für diese Gruppen aktualisieren, nachdem Sie Informationsbarrieren bereitgestellt haben. Gruppen, die vor der Aktivierung von IB bereitgestellt wurden, werden dem Modus "Öffnen" zugewiesen. Im Offenen Modus gibt es keine anwendbaren IB-Richtlinien. Nachdem Sie IB aktiviert haben, wird Implizit zum Standardmodus für alle neuen Gruppen, die Sie erstellen. Vorhandene Gruppen behalten jedoch weiterhin die Konfiguration des Offenen Modus bei. Führen Sie dieses Skript aus, um diese vorhandenen Gruppen in den impliziten Modus zu ändern.

In diesem Skript verwenden Sie das Cmdlet Get-UnifiedGroup, das sich im Exchange Online PowerShell-Modul befindet, um den Modus zu aktualisieren. Weitere Informationen zum Verwalten von Teams mithilfe von PowerShell finden Sie unter Übersicht über Teams PowerShell.

Beispielskript

Sie müssen ein Geschäfts-, Schul- oder Unikonto verwenden, dem die globale Administratorrolle für Ihren Mandanten zugewiesen wurde, um dieses Skript auszuführen.

<#
.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.")) 
}