Last active
April 15, 2025 17:37
-
-
Save BiatuAutMiahn/f2eeec551d59b987424e41793d435c7f to your computer and use it in GitHub Desktop.
do AD Sync /w Feedback
This file contains hidden or 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() { | |
Write-Host "[doADSync v1.2]" | |
$iProg=1 | |
$aProg="|","/","-","\","|","/","-","\" | |
Write-Host "Checking ADSync Module..." -NoNewLine | |
if (-Not (Get-Module -ListAvailable -Name AdSync)) { | |
Write-Host "AdSync Module not Available!" | |
return $false | |
} | |
Write-Host "`b`b`b, Importing..." -NoNewLine | |
try { | |
Import-Module AdSync | |
Write-Host "Done" | |
} catch { | |
Write-Host "Failed, Exception:`n$($_.Exception.Message)"; | |
return; | |
} | |
Write-Host "Checking if Sync is in progress..." -NoNewLine | |
$sync = Get-AdSyncScheduler | |
if ($sync.SyncCycleInProgress -eq $False) { | |
Write-Host "No" | |
Write-Host -NoNewline "Triggering Delta Sync Cycle..." | |
$status = Start-AdSyncSyncCycle -Policytype "Delta" -ErrorAction Stop | |
if (($status.Result -eq "Success") -and (-not $MyError)) { | |
Write-Host "Done" | |
} Else { | |
Write-Host "Failed, Exception:`n$($_.Exception.Message)"; | |
return | |
} | |
Write-Host -NoNewline ("Waiting for Sync Cycle to start {0} " -f $aProg[0]) | |
do { | |
$sync = Get-AdSyncScheduler | |
Write-Host -NoNewline ("`b`b{0} " -f $aProg[$iProg++]) | |
if ($iProg -gt $aProg.length-1) { | |
$iProg=0 | |
} | |
Start-Sleep -Milliseconds 125 | |
} until ($sync.SyncCycleInProgress -eq $True) | |
Write-Host -NoNewline "`b`b`b..." | |
Write-Host "Done" | |
} else { | |
Write-Host "Yes" | |
} | |
Write-Host -NoNewline ("Waiting for Sync Cycle to finish {0} " -f $aProg[0]) | |
do { | |
$sync = Get-AdSyncScheduler | |
Write-Host -NoNewline ("`b`b{0} " -f $aProg[$iProg++]) | |
if ($iProg -gt $aProg.length-1) { | |
$iProg=0 | |
} | |
Start-Sleep -Milliseconds 125 | |
} until ($sync.SyncCycleInProgress -eq $False) | |
Write-Host -NoNewline "`b`b`b..." | |
Write-Host "Sync Cycle Finished" | |
} | |
#cls # uncomment to clear the screen with each run. | |
doADSync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment