1. You must put on your DC psexec.exe to your %systemroot%\system32 you can download it from here https://download.sysinternals.com/files/PSTools.zip
2. Create in your DirSync server script DirSync-SYNC.ps1 in your prefered folder c:\scripts and add this content:

Import-Module ADSync
Start-ADSyncSyncCycle -PolicyType Delta

Save it.
3. Now create batch file DirSync-SYNC.bat in the same folder that must run our C:\scripts\DirSync-SYNC.ps1 with this content:

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\Scripts\DirSync-SYNC.ps1""' -Verb RunAs}"

Save it
4. Now you can create batch file on your DC that can run your remote script.
5. Create script with this content:

@echo off
psexec.exe \\Your_DirSync_server c:\Scripts\DirSync-SYNC.bat

Also you can automate your sync process to add to your event viewer scheduled task on event when new user or group or user changed password changed created:
1 . For do this open Event viewer and find this alerts:

 

 

 

One thought to “Office 365 – How to run DirSync manualy or by event viewer from another server”

Leave a comment

Your email address will not be published. Required fields are marked *