Modificare le modalità di barriere informative con uno script di PowerShell

Usare questo script di PowerShell per aggiornare la modalità IB (Information Barriers) per tutti i gruppi connessi a Teams nel tenant. Dopo aver distribuito le barriere informative, sarà necessario aggiornare la modalità per questi gruppi. Ai gruppi di cui è stato eseguito il provisioning prima di abilitare LB viene assegnata la modalità Apri . In modalità Aperta non sono presenti criteri IB applicabili. Dopo aver abilitato IB, Implicit diventa la modalità predefinita per tutti i nuovi gruppi creati. Tuttavia, i gruppi esistenti mantengono la configurazione in modalità Aperta . Eseguire questo script per modificare questi gruppi esistenti in modalità implicita .

In questo script si userà il cmdlet Get-UnifiedGroup, disponibile nel modulo Exchange Online PowerShell per aggiornare la modalità. Per altre informazioni sulla gestione di Teams tramite PowerShell, vedere Panoramica di Teams PowerShell.

Script di esempio

Per eseguire questo script, è necessario usare un account aziendale o dell'istituto di istruzione a cui è stato assegnato il ruolo di amministratore globale per il tenant.

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