Quantcast
Channel: Azure Management Portal forum
Viewing all articles
Browse latest Browse all 4189

Script to automate fix for Sync Error due to Deletion Threshold Limit

$
0
0

I wrote this script so the operational process to fix this error is as easy as can be. User should log into the Azure AD Sync Server, open powershell (Not the azure module) and run this script. User must be Global Admin (or at least mine are, you may be able to limit this to s specific role but our people are admins).

PS: We perform monthly account maintenance that causes 500+ deletions, if you typically do not do this, you most definitely want to investigate WHY you are seeing that many deletions. This script is for those who KNOW they are supposed to have that many, and want them processed.

Script stops current sync if they exist, disables the threshhold, starts an intial sync, and once sync is completed, it re-enables the threshhold at 500 (default limit)

$Cred=get-credential
write-host -ForegroundColor yellow "Stopping all active Syncs"
Set-ADSyncScheduler -SyncCycleEnabled $false
Write-Host -ForegroundColor Yellow "Disabling Deletion Threshold Limit."
Disable-ADSyncExportDeletionThreshold -AADCredential $Cred
Write-Host -ForegroundColor Yellow "Enabling Sync Service."
Set-ADSyncScheduler -SyncCycleEnabled $true
Write-Host -ForegroundColor Yellow "Starting a Full Sync!"
Start-ADSyncSyncCycle -PolicyType Initial
$date=get-date
Do {
write-host "Sync in progress...please wait... this Sync can take up to an hour." -ForegroundColor Yellow
$result = Get-EventLog -Source 'Directory Synchronization' -LogName Application -InstanceId 904 -after $date -Message "Import/Sync/Export cycle completed (Initial)." -ErrorAction SilentlyContinue
If($result){Break}
Start-Sleep -Seconds 60
} while (!$result)
write-host -ForegroundColor Yellow "Sync Completed! .... Re-Enabling Deletion Threshold Limit."
Enable-ADSyncExportDeletionThreshold -DeletionThreshold 500 -AADCredential $Cred
Start-Sleep -Seconds 2
Write-Host -ForegroundColor Yellow "Script Complete!"

Hope this helps others :), made it possible to operationalize this at a Help Desk Level essentially.



Viewing all articles
Browse latest Browse all 4189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>