Partager via


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

Utilisez ce script PowerShell pour mettre à jour le mode Barrières à l’information (IB) pour tous les groupes connectés à Teams dans votre locataire. Vous devez mettre à jour le mode pour ces groupes après avoir déployé Information Barriers. Le mode Ouvrir est attribué aux groupes créé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 utilisez 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

Importante

Microsoft vous recommande d’utiliser des rôles disposant du moins d’autorisations. La réduction du nombre d’utilisateurs disposant du rôle Administrateur général permet d’améliorer la sécurité de vos organization. En savoir plus sur les rôles et autorisations Microsoft Purview.

Pour exécuter ce script, utilisez un compte professionnel ou scolaire qui a le rôle d’administrateur général pour votre locataire.

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