Modifier les modes d’obstacle à l’information avec un script PowerShell

Utilisez ce script PowerShell pour mettre à jour le mode d’obstacles à l’information (IB) pour tous les groupes connectés à Teams dans votre locataire. Vous devrez mettre à jour le mode pour ces groupes après avoir déployé des barrières à l’information. Le mode Ouvert est attribué aux groupes approvisionnés avant d’activer IB. En mode Ouvert , il n’existe aucune stratégie IB applicable. Une fois que vous avez activé IB, Implicite devient le mode par défaut pour tous les nouveaux groupes que vous créez. Toutefois, les groupes existants conservent toujours la configuration en mode Ouvert . Exécutez ce script pour remplacer ces groupes existants en mode implicite .

Dans ce script, vous allez utiliser l’applet de commande Get-UnifiedGroup, qui se trouve dans le module PowerShell Exchange Online pour mettre à jour le mode. Pour en savoir plus sur la gestion de Teams à l’aide de PowerShell, consultez Vue d’ensemble de Teams PowerShell.

Exemple de script

Vous devez utiliser un compte professionnel ou scolaire auquel le rôle d’administrateur général a été attribué à votre locataire pour exécuter ce script.

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