Hello JIn,
Thanks for contacting MS Q&A. I will assist you with resolving your issues regarding decommissioning the on-premises server users' accounts and making the users' accounts cloud-only.
You're absolutely right to proceed with caution — disabling directory synchronization (DirSync
) without proper preparation can result in loss of user management capabilities or even account deletions, depending on how things are configured.
What Set-MsolDirSyncEnabled -EnableDirSync $False
Does:
This command disables Azure AD Connect synchronization between your on-premises Active Directory and Microsoft 365 (Azure AD). Once disabled:
- Existing users synced from on-premises become “cloud-managed” accounts — meaning you can now edit them directly in Microsoft 365 (Azure AD).
- However, if not done correctly, there's a risk those synced accounts may get deleted or deactivated.
Safe Steps to Convert Synced Users to Cloud-Only Accounts
To safely decommission your on-prem AD and retain the M365 accounts, follow these best practices:
- Confirm All Users Are in Sync and Stable: Ensure no sync issues exist: Start-ADSyncSyncCycle -PolicyType Delta. Then verify in the Microsoft 365 Admin Center or Azure AD that all users have
source = Windows Server AD
- Export a Backup of User Details: Use PowerShell or Azure AD to export all user objects as a precaution: Get-MsolUser | Select-Object DisplayName, UserPrincipalName, ImmutableId | Export-Csv users-backup.csv -NoTypeInformation
- Clear ImmutableId (Optional But Safer): If you want users to become native cloud accounts, it’s highly recommended to clear their
ImmutableId
first, before disabling DirSync: Get-MsolUser -All | where {$_.ImmutableId -ne $null} | ForEach-Object {
} This breaks the sync link for each user while keeping their cloud account intact.Set-MsolUser -UserPrincipalName $_.UserPrincipalName -ImmutableId $null
- Disable DirSync: Once all accounts are cleared of
ImmutableId
, run: Set-MsolDirSyncEnabled -EnableDirSync $false This tells Microsoft 365 that you're no longer syncing users from on-prem. - Wait for Sync Disable to Take Effect: This may take up to 72 hours but is usually done within 24 hours. You can check status with: (Get-MsolCompanyInformation).DirectorySynchronizationEnabled
- Confirm Accounts Are Now Cloud-Managed: Check in Azure AD or M365 Admin Center — accounts should now be editable in the cloud, and
source
should change to "Azure Active Directory". Note: Do Not Just Disable DirSync Without Clearing ImmutableId If you run the command without first clearingImmutableId
, Azure AD may see those users as orphaned and could soft-delete them. I hope this helps.