iTranslated by AI
Trying out alternatives to Set-MsolDirSyncEnabled
TL;DR
-
Set-MsolDirSyncEnabledhas been deprecated -
Update-MgBetaOrganizationand others serve as its replacement - Installing
Microsoft.GraphandMicrosoft.Graph.Betamodules makes tab completion slow...
Introduction
I often build and tear down configurations of Active Directory (AD) + Microsoft Entra Connect (formerly Azure AD Connect) for tasks such as Azure Virtual Desktop (AVD) validation.
When tearing them down, I feel like I should delete the users registered in Microsoft Entra ID, but to do that, I first need to remove the Microsoft Entra Connect settings.
I had been using the Set-MsolDirSyncEnabled command for a long time, and now that its next-generation version has finally been released, I've given it a try.
Set-MsolDirSyncEnabled
The documentation is Set-MsolDirSyncEnabled.
To use this cmdlet, you need to install the MSOnline module, but it has been declared at the beginning of the MSOnline Module documentation that it will be deprecated as of March 30, 2024.
However, a replacement for it hadn't really appeared for quite some time.
Update-MgBetaOrganization and others
The group of commands including Update-MgBetaOrganization is what has emerged as the replacement.
The documentation is Turn off directory synchronization for Microsoft 365.
It feels a bit like calling a raw API; you log in, create a parameter object for the body, and then submit it.
I tried it the other day and it worked correctly, so I am relieved that a replacement for Set-MsolDirSyncEnabled—or rather, what I should be using going forward—has been established.
The problem occurs after installing the Microsoft.Graph and Microsoft.Graph.Beta modules to use this.
Perhaps because these modules contain too many cmdlets, tab completion starts taking a significantly longer time.
However, when opening a new PowerShell window or starting a new session, it becomes quite slow, possibly because it performs an action equivalent to Import-Module for all modules listed by Get-InstalledModule.
Although "slow" means it finishes within seconds, it feels about three times slower than usual, which is somewhat frustrating...
So, I thought about deleting them after use, but perhaps due to the complex dependencies between Microsoft.Graph and Microsoft.Graph.Beta, Uninstall-Module doesn't seem to remove them easily.
Therefore, as a precaution, I closed all PowerShell sessions, navigated to Documents\PowerShell\Modules, and deleted all folders that seemed related.
I'll perform proper troubleshooting when I feel like it.
Conclusion
I have used Set-MsolDirSyncEnabled for a long time, but since the MSOnline module is being deprecated, let's shift to using commands like Update-MgBetaOrganization provided by Microsoft.Graph and Microsoft.Graph.Beta going forward.
Discussion