關閉 Microsoft 365 的目錄同步處理
您可以使用 PowerShell 來關閉目錄同步處理,並將同步處理的使用者轉換為僅限雲端。 不過,不建議您關閉目錄同步處理作為疑難解答步驟。 如果您需要目錄同步處理疑難解答的協助,請參閱 修正 Microsoft 365 的目錄同步處理問題 一文。
如果您需要此程序的協助,請連絡支持人員。
注意事項
如果您的目標是要永久停用租使用者中的同步處理,您應該先卸載同步處理用戶端 (,例如 Connect Sync 或 Cloud Sync) 。 在卸載同步處理用戶端之前停用同步處理,可能會導致 Entra Id 入口網站將目錄同步處理顯示為 已停用,但密碼哈希同步處理等選擇性功能會顯示為 已啟用。 雖然這應該不會造成任何問題,而且當目錄同步處理停用時,選擇性功能將無法運作,但可能會在入口網站中導致非預期的狀態。
關閉目錄同步處理
若要關閉目錄同步處理:
首先,安裝必要的軟體,並連線到您的 Microsoft 365 訂用帳戶。 如需指示,請參閱使用 Microsoft Graph PowerShell 模組連線以取得 Windows PowerShell。
使用 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 Hybrid Identity Administrator 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-MgOrganization -OrganizationId $organizationId -BodyParameter $params
# Check that the command worked
Get-MgOrganization | Select OnPremisesSyncEnabled
注意事項
如果您使用此命令,您必須等候 72 小時,才能重新開啟目錄同步處理。 此程式會清除下列內部部署屬性:
- DnsDomainName
- NetBiosName
- OnPremisesDistinguishedName
- OnPremisesSamAccountName
- OnpremisesUserPrincipalName