Last active
December 13, 2019 00:25
-
-
Save rob89m/e04e1029d41888eb7d80ce5b69514da3 to your computer and use it in GitHub Desktop.
SyncAzureAD #PowerShell #Azure #O365
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
<# | |
.DESCRIPTION | |
Simple script to run AzureADSync. | |
Compiling using PS2EXE-GUI (https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI-Convert-e7cb69d5) to an exe makes an easy tool to quickly trigger an Azure AD Sync. | |
.EXAMPLE | |
AzureADSync.ps1 | |
#> | |
# Create Timestamp Information | |
$Date = get-date -Format 'yyyy-MM-dd_hh-mm-ss' | |
# Define log path | |
$Logs = "C:\Logs" | |
# Confirm Log Path exists | |
$LogsTest = Test-Path $Logs | |
if($LogsTest -eq $False) | |
{# Log path does't exists | |
Write-Host "Path $Logs doesn't exist... Creating it now" | |
# Create Log Path | |
mkdir $Logs | |
Write-Host "Path created" | |
Write-Host "Proceeding to sync AD to Azure" | |
} | |
&{# Start Azure AD Sync | |
Write-Host "AzureADSync Starting... Please allow upto 3 minutes for sync to complete" | |
Start-ADSyncSyncCycle -PolicyType Delta | |
} *>> "C:\Logs\AzureADSync($Date).txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment