Last active
June 12, 2024 21:16
-
-
Save BiatuAutMiahn/f2eeec551d59b987424e41793d435c7f to your computer and use it in GitHub Desktop.
do AD Sync /w Feedback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doADSync() { | |
$iProg=1 | |
$aProg="|","/","-","\","|","/","-","\" | |
if (-Not (Get-Module -ListAvailable -Name AdSync)) { | |
Write-Host "AdSync Module not Available!" -ForegroundColor "Magenta" | |
return $false | |
} | |
Import-Module AdSync | |
$sync = Get-AdSyncScheduler | |
if ($sync.SyncCycleInProgress -eq $False) { | |
Write-Host -NoNewline "Triggering Delta Sync Cycle..." -ForegroundColor "Cyan" | |
$status = Start-AdSyncSyncCycle -Policytype "Delta" -ErrorVariable "MyError" -ErrorAction SilentlyContinue | |
if (($status.Result -eq "Success") -and (-not $MyError)) { | |
Write-Host "Done" -ForegroundColor "Green" | |
} Else { | |
Write-Host "Fail" -ForegroundColor "Red" | |
return $MyError | |
} | |
} else { | |
Write-Host "Warning, Sync Cycle already running!" -ForegroundColor "Yellow" | |
} | |
Write-Host -NoNewline ("Waiting for Sync Cycle to finish {0} " -f $aProg[0]) -ForegroundColor "Cyan" | |
do { | |
$sync = Get-AdSyncScheduler | |
Write-Host -NoNewline ("`b`b{0} " -f $aProg[$iProg++]) -ForegroundColor "Cyan" | |
if ($iProg -gt $aProg.length-1) { | |
$iProg=0 | |
} | |
Start-Sleep -Milliseconds 250 | |
} until ($sync.SyncCycleInProgress -eq $False) | |
Write-Host -NoNewline "`b`b`b..." -ForegroundColor "Cyan" | |
Write-Host "Sync Cycle Finished" -ForegroundColor "Green" | |
} | |
cls | |
doADSync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment