SOLVED

Using the <Start-ADSyncSyncCycle -PolicyType Delta> command remotely.

Copper Contributor

 

 

Hello all,

 

I have an Exchange Hybrid between Office 365 and Exchange 2013 on-prem. For this to work we have the Azure AD Connect application installed on the Exchange server. It syncs every half hour and in order to force a sync, as needed in certain situations, we login to the server remotely and run the command <Start-ADSyncSyncCycle -PolicyType Delta> to force a sync. Works everytime and this makes sure that the Active Directory users attributes related to mailbox parameters are copied between the cloud and on-prem. I have tried initiating a remote Exchange Powershell session from other Exchange servers using <Import-PSSession> and <Enter-PSSession> after creating a New-PSSession. This all works but I get an error when I run the command <Start-ADSyncSyncCycle -PolicyType Delta> in both Import and Enter PSSession options. 

 

Jessterf_1-1627679789955.png

 

Jessterf_0-1627679384830.png

 

Any Ideas on what I am doing wrong would be greatly appreciated. I am new to the ocean of Powershell so I am pretty sure it is user error on my part.

 

Thanks

 

 

4 Replies
This won't work, the Start-ADSYncSyncCycle command is not part of the Exchange Server PowerShell module, its is part of the ADSync PS Module.


-------
Please mark this answer as best response if it helps
best response confirmed by Jessterf (Copper Contributor)
Solution

@Jessterf, there are two options.

You can just use Enter-PSSession, without first importing the Exchange session:

Enter-PSSession ExchangeServername
Start-ADSyncSyncCycle -PolicyType delta
Exit-PSSession

 Or you can use Invoke-Command:

Invoke-Command -ScriptBlock { Start-ADSyncSyncCycle -PolicyType delta } -ComputerName ExchangeServername

 

Make sure WinRM or PSRemoting are configured on your Exchange Server (winrm quickconfig or Enable-PSremoting)

@RGijsbersRademakers 

Wow that was simple.......

Thank you for that......

Now the world knows I have a big L on my forehead!

@Jessterf

No problem, happy to help. And don't worry, there's definitely no big  L on your forehead. :smile:

1 best response

Accepted Solutions
best response confirmed by Jessterf (Copper Contributor)
Solution

@Jessterf, there are two options.

You can just use Enter-PSSession, without first importing the Exchange session:

Enter-PSSession ExchangeServername
Start-ADSyncSyncCycle -PolicyType delta
Exit-PSSession

 Or you can use Invoke-Command:

Invoke-Command -ScriptBlock { Start-ADSyncSyncCycle -PolicyType delta } -ComputerName ExchangeServername

 

Make sure WinRM or PSRemoting are configured on your Exchange Server (winrm quickconfig or Enable-PSremoting)

View solution in original post