We have an ADFS environment which our AD has a one-way sync with O365. Any changes we have to make, we have to do in AD. One of our consultants supplied us with two commands that allow us to force a sync between our AD up to O365.
Once I finish making changes in our AD:
- On our server with AD, I go to Start --> Run --> repadmin /syncall /e:
- Log off once the command window finishes running
- Log into our ADFS server
- Run a file called DirSyncConfigShell.psc1
- This file contains the following code:
<?xml version="1.0" encoding="utf-8"?><PSConsoleFile ConsoleSchemaVersion="1.0"><PSVersion>1.0</PSVersion><PSSnapIns><PSSnapIn Name="Coexistence-Configuration" /></PSSnapIns></PSConsoleFile>
- When you run that file, a black PowerShell command window opens
- Type Start-OnlineCoexistenceSync and press enter.
- Log off and the AD to O365 sync is completed
What I would like to know is if there is a way that I can do this from a single batch command, PowerShell or something. We do this frequently enough that it would be great to be able to run steps 4-6 right from our AD server. I know there is a tool call PSEXEC that supposed to let you remotely run commands but not sure how this would work. Both our AD server and ADFS server are on the same domain.
Anyone have any advice?