skip to Main Content

Force sync Azure AD Connect with PowerShell

We made urgent changes in the on-premises AD objects, and we like to have it synced with Azure AD. By default, every 30 minutes, a synchronization cycle is run. We can wait for 30 minutes, or we force synchronize the changes manually. Let’s go with option two and force sync Azure AD Connect with PowerShell.

Find Azure AD Connect server

How to know on which server Azure AD Connect is installed on? Find the server with PowerShell or in the Azure Portal.

PowerShell

Start PowerShell as administrator. Make sure that you have privileges to search in Active Directory. After running the cmdlet, we do know that it’s installed on the server DC02.

PS C:\> Get-ADUser -LDAPFilter "(description=*configured to synchronize to tenant*)" -Properties description | % { $_.description.SubString(142, $_.description.IndexOf(" ", 142) -142)}
DC02

Azure Portal

Log in to Azure Portal. Go to Azure AD Connect > Azure Active Directory Connect Health > Sync Services. Find the server in the Azure Active Directory Connect Servers tile.

Force sync Azure AD Connect with PowerShell Azure

Azure AD Connect scheduler configuration

Check the scheduler configuration. Log 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 log into the server where Azure AD Connect is installed? We can run the cmdlets in PowerShell from another server. For example, we are on server MG01. That’s the management server. Make use of the Enter-PSSession cmdlet to connect to the server DC02. In the end, make use of 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 are going to 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 do a full sync from AD on-premises to Azure AD. Remember that the initial sync can take more time.

PS C:\> Start-ADSyncSyncCycle -PolicyType Initial

Result
------
Success

Azure AD Connect disable scheduler

Disable the Azure AD Connect sync scheduler if you have a lot of changes on-premises. That will let the scheduler not to 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: Cleanup Exchange logs automatically with scheduled task »

Conclusion

In this article, 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 it.

Did you enjoy this article? You may also like Turn off Windows Defender in Windows 10 permanently. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *