Start Azure AD Connect AD Sync From a Remote Machine Using PowerShell

In this blog post, I will show you how to start Azure AD connect (also knows as ADsync)  Active Directory sync to Office 365 from a remote machine using PowerShell.

In my case, I needed to start AD sync from a remote machine as part of a migration script.

Code

The following code is using the invoke-command script to connect to the Azure AD Connect server and start a delta script.

The code also waits for confirmation before exiting.

$ErrorActionPreference = "Inquire"
Invoke-Command -ComputerName  AZUREADSERVER -ScriptBlock {Start-ADSyncSyncCycle -PolicyType delta} 
Read-Host -Prompt "Press Enter to exit"

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.