Hybrid Modern Authentication (HMA) is implemented in the on-premises organization. This way, the users with…
Force sync Azure AD Connect with PowerShell
We made urgent changes in the on-premises AD objects, and we like to have them synced with Azure AD. By default, every 30 minutes, a synchronization cycle is run. We can wait for 30 minutes or force synchronize the changes manually. Let’s go with option two and force sync Azure AD Connect with PowerShell.
Table of contents
Find Azure AD Connect server
How to know on which server Azure AD Connect is installed? Find the server with Windows PowerShell or in Microsoft Azure Portal.
Windows PowerShell
Start PowerShell as administrator. Make sure that you have privileges to search in Active Directory. After running the cmdlet, we know that AAD Connect is installed on Windows Server DC02.
PS C:\> Get-ADUser -LDAPFilter "(description=*configured to synchronize to tenant*)" -Properties description | % { $_.description.SubString(142, $_.description.IndexOf(" ", 142) -142)}
DC02
Suppose you did create an AD DS Connector account instead of the default AD DS Connector account when installing Azure AD Connect. It will not show the Azure AD Connect server with the above PowerShell cmdlet. Go through the next step and locate the Azure AD Connect server.
Microsoft Azure Portal
To find the Azure AD Connect server, follow these steps:
- Sign in to Microsoft Azure Portal
- Click on Menu > Azure Active Directory
- Select Azure AD Connect > Azure AD Connect Health
- Click on Sync services > Service name
The picture below shows that Azure Active Directory Connect Server is installed on Windows Server DC02.
Read more: How to find Azure AD Connect server »
Azure AD Connect scheduler configuration
Check the scheduler configuration. Sign in to the Windows Server, where you have the Azure AD connect installed. Start PowerShell as administrator and run Import-Module ADSync. Follow with the Get-ADSyncScheduler cmdlet.
PS C:\> Import-Module ADSync
PS C:\> Get-ADSyncScheduler
AllowedSyncCycleInterval : 00:30:00
CurrentlyEffectiveSyncCycleInterval : 00:30:00
CustomizedSyncCycleInterval :
NextSyncCyclePolicyType : Delta
NextSyncCycleStartTimeInUTC : 19-8-2020 10:30:00
PurgeRunHistoryInterval : 7.00:00:00
SyncCycleEnabled : True
MaintenanceEnabled : True
StagingModeEnabled : False
SchedulerSuspended : False
SyncCycleInProgress : False
What if you don’t want to sign in to the server where Azure AD Connect is installed? We can run the cmdlets in PowerShell from another server.
For example, we are on the Management Server MG01. Run the Enter-PSSession cmdlet to connect to the server DC02. In the end, run the Exit-PSSesion cmdlet to exit the interactive session.
PS C:\> Import-Module ADSync
PS C:\> Enter-PSSession -ComputerName DC02
[DC02]: PS C:\> Get-ADSyncScheduler
AllowedSyncCycleInterval : 00:30:00
CurrentlyEffectiveSyncCycleInterval : 00:30:00
CustomizedSyncCycleInterval :
NextSyncCyclePolicyType : Delta
NextSyncCycleStartTimeInUTC : 19-8-2020 10:30:00
PurgeRunHistoryInterval : 7.00:00:00
SyncCycleEnabled : True
MaintenanceEnabled : True
StagingModeEnabled : False
SchedulerSuspended : False
SyncCycleInProgress : False
In the next step, we will run the cmdlets to force sync Azure AD Connect.
Force sync Azure AD (delta sync cycle)
The delta sync will only sync the changes from AD on-premises to Azure AD.
PS C:\> Start-ADSyncSyncCycle -PolicyType Delta
Result
------
Success
Force sync Azure AD (initial sync cycle)
The initial sync will fully sync from AD on-premises to Azure AD. However, remember that the initial sync can take longer than the delta sync.
PS C:\> Start-ADSyncSyncCycle -PolicyType Initial
Result
------
Success
Azure AD Connect disable scheduler
Disable the Azure AD Connect sync scheduler if you have many changes on-premises. That will let the scheduler not kick in. When done, enable Azure AD Connect sync scheduler.
PS C:\> Set-ADSyncScheduler -SyncCycleEnabled $false
PS C:\> Set-ADSyncScheduler -SyncCycleEnabled $true
Did this article help you to force sync Azure AD Connect with PowerShell?
Keep reading: Find Azure AD Connect accounts »
Conclusion
You learned how to force sync Azure AD Connect with PowerShell. The default sync is 30 minutes, but that doesn’t mean that we can’t force it. Make use of the Delta and Initial sync cmdlets. Microsoft did write an excellent document about the Azure AD Connect sync scheduler.
Did you enjoy this article? You may also like Migrate Azure AD Connect to new server. Don’t forget to follow us and share this article.
This Post Has 0 Comments