關閉 Microsoft 365 的目錄同步處理

您可以使用 PowerShell 來關閉目錄同步處理,並將同步處理的使用者轉換為僅限雲端。 不過,不建議您關閉目錄同步處理作為疑難解答步驟。 如果您需要目錄同步處理疑難解答的協助,請參閱 修正 Microsoft 365 目錄同步處理的問題 一文。

如果您需要此程序的協助,請連絡支持人員。

關閉目錄同步處理

若要關閉目錄同步處理:

  1. 首先,安裝必要的軟體並連線到您的 Microsoft 365 訂閱。 如需指示,請參閱使用適用於 Windows PowerShell 的 Microsoft Graph 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