AD Connect: The term ‘Start-ADSyncSyncCycle’ is not recognized

Just a brief post today to outline how to rectify an issue when you try and run a sync via PowerShell using the command:

Start-ADSyncSyncCycle -PolicyType Initial

and then you receive the error message:

Start-ADSyncSyncCycle : The term 'Start-ADSyncSyncCycle' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ Start-ADSyncSyncCycle -PolicyType Initial
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Start-ADSyncSyncCycle:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I had just installed the latest version of AD Connect and had prepared Active Directory for replication to Azure AD. I couldn't understand why, after a fresh install, that the ADSync modules weren't present and available.

You can run the following command to see what modules are available:

get-Module

When I ran that, my instance returned:

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...

As you can see, ADSync is not listed so that explains why my attempt to run the sync wouldn't run. So how do you fix it? The method I used was as follows...

Open an Administrator instance of PowerShell run the following commands:

First, we're going to set the execution policy of PowerShell:

Set-ExecutionPolicy RemoteSigned

Now we're going to import the ADSync module from the ADSync installation directory on your server. In my case it was located in:

C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync

But be aware, yours may be different depending on the drive and folder it was installed into. With that knowledge, you need to change the path in the syntax below to suit your set up:

Import-Module -Name "C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync" -Verbose

That will now import all the modules from the ADSync directory and make the available to PowerShell. To test whether the import was successful run the following command:

get-module

It should return something similar to the following with ADSync listed as one of the available modules:

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.0    ADSync                              {Add-ADSyncAADServiceAccount, Add-ADSyncADDSConnectorAccou...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script     1.0.0.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...

Now you should be able to run the ADSyncSyncCycle command like so:

Start-ADSyncSyncCycle -PolicyType Initial

and it should return the following result:

PS C:\Users\Administrator> Start-ADSyncSyncCycle -PolicyType Initial

 Result
 ------
Success

That's it, you're good to go...

If you've found this useful, you may want to sign up to our newsletter where you'll receive notices on when we post new articles and helpful "how tos". Just fill out your details below and we'll do the rest...

No Comments Yet.

Leave a comment


Sign up to our newsletter where you’ll receive notices on when we post new articles and helpful “how tos” to make your IT life easier.