Facebook
From Beefy Owl, 9 Months ago, written in Plain Text.
This paste is a reply to ps1 from Chartreuse Lizard - view diff
Embed
Download Paste or View Raw
Hits: 100
  1. Import-Module –Name "C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync" #-Verbose
  2.  
  3. # Get the next Sync scheduled run and ask the user if it's wise to manually start it now
  4. $nextrun = Get-ADSyncScheduler | Select -ExpandProperty NextSyncCycleStartTimeInUTC
  5. $nextruntime = Convert-UTCtoLocal($nextrun)
  6. echo "Next run planned for $nextruntime Continue?"
  7. $confirmation = Read-Host "Are you Sure You Want To Proceed (y\n)"
  8. if ($confirmation -eq 'y') {
  9.     # See if the cycle isnt in progress yet
  10.     $inprogress = Get-ADSyncScheduler | Select -ExpandProperty SyncCycleInProgress
  11.     if($inprogress -eq $True)
  12.     {
  13.         echo "Cycle is already running. Exiting script."
  14.         exit
  15.     }else{
  16.         # Run the Sync!
  17.         # https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sync-feature-scheduler
  18.        
  19.         # Force Delta Sync:
  20.             # Delta import on all Connectors
  21.             # Delta sync on all Connectors
  22.             # Export on all Connectors
  23.         Start-ADSyncSyncCycle -PolicyType Delta -InteractiveMode $True
  24.        
  25.         # Full (Initial) Sync. (Niet nodig voor groups etc)
  26.         #Start-ADSyncSyncCycle -PolicyType Initial
  27.     }
  28. }
  29.  
  30.  
  31.  
  32. # Functie om de UTC naar local time te veranderen
  33. function Convert-UTCtoLocal
  34. {
  35. param(
  36. [parameter(Mandatory=$true)]
  37. [String] $UTCTime
  38. )
  39.  
  40. $strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName
  41. $TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)
  42. $LocalTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ)
  43. return $LocalTime
  44. }