关闭 Microsoft 365 的目录同步

可以使用 PowerShell 关闭目录同步,并将同步的用户转换为仅限云的用户。 但是,不建议关闭目录同步作为故障排除步骤。 如果在排查目录同步问题方面需要帮助,请参阅 修复 Microsoft 365 目录同步问题 一文。

如果需要此过程的帮助,请联系支持人员

关闭目录同步

若要关闭目录同步,请执行以下操作:

  1. 首先,安装所需的软件并连接到 Microsoft 365 订阅。 有关说明,请参阅使用 Microsoft Graph PowerShell 模块进行连接以Windows PowerShell

  2. 使用 Update-MgBetaOrganization 禁用目录同步:

  # Install v1.0 and beta Microsoft Graph PowerShell modules 
  Install-Module Microsoft.Graph -Force
  Install-Module Microsoft.Graph.Beta -AllowClobber -Force 
  
  # Connect With Global Admin Account
  Connect-MgGraph -scopes "Organization.ReadWrite.All,Directory.ReadWrite.All" 
  
  # Verify the current status of the DirSync Type
  Get-MgOrganization | Select OnPremisesSyncEnabled 
  
  # Store the Tenant ID in a variable named organizationId
  $organizationId = (Get-MgOrganization).Id 
  
  # Store the False value for the DirSyncEnabled Attribute
  $params = @{
  	onPremisesSyncEnabled = $false
  }
  
  # Perform the update
  Update-MgBetaOrganization -OrganizationId $organizationId -BodyParameter $params 
  
  # Check that the command worked
  Get-MgOrganization | Select OnPremisesSyncEnabled

注意

如果使用此命令,则必须等待 72 小时才能重新打开目录同步。

有关 cmdlet 用法和开关的更多详细信息,请访问 Update-MgBetaOrganization