title: Azure AD Connect Start-ADSyncSyncCycle causes error
body: <p>We are using Office 365 Business and have our Active Directory synchronised using Azure AD Connect. According to the portal the synchronisation is working ok however when we try to run PowerShell commands on the server running Azure AD Connect we just get error messages.</p>
  
  <p>For example trying to force a synchronisation using <code>Start-ADSyncSyncCycle -PolicyType Initial</code> causes the below error. Similar errors happen when we run <code>Get-ADSyncAutoUpgrade</code> etc.</p>
  
  <p>Does anyone know what the cause would be and how to resolve? It appears the synchronisation is actually working as the portal reports that it happened "X minutes ago" however we have Googled some parts of the large error below without much results.</p>
  
  <pre><code>PS C:\Users\Administrator.DOMAIN&gt; Start-ADSyncSyncCycle -PolicyType Initial
  Start-ADSyncSyncCycle :
  System.Management.Automation.CmdletInvocationException: System.Exception:
  Unexpected exception thrown. Action:
  ProvisioningWebServiceAdapter::GetCompanyConfiguration, Exception:  ---&gt;
  System.Runtime.InteropServices.COMException
     at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
  errorCode, IntPtr errorInfo)
     at System.Management.ManagementObject.Initialize(Boolean getObject)
     at System.Management.ManagementBaseObject.get_Properties()
     at System.Management.ManagementBaseObject.GetPropertyValue(String
  propertyName)
     at Microsoft.Online.DirSync.Common.PrerequisiteChecks.TryMachineIsDomainCont
  rollerCore()
     at Microsoft.Online.Coexistence.ProvisionHelper.IsMachineDomainController()
     at Microsoft.Online.Coexistence.ProvisionHelper.GenerateSyncToken()
     at Microsoft.Online.Coexistence.ProvisionHelper.OpenProxyConnection()
     at Microsoft.Online.Coexistence.ProvisionHelper.InvokeAwsAPI[T](Func`1
  awsOperation, String opsLabel)
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.&lt;&gt;c__DisplayClass1.&lt;GetCompanyConfiguration&gt;
  b__0()
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName, Action
  action)
     --- End of inner exception stack trace ---
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName, Action
  action)
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.GetCompanyConfiguration(Boolean
  includeLicenseInformation)
     at Microsoft.Azure.ActiveDirectory.Synchronization.AADConfig.get_CloudEnforc
  edSyncSchedulerInterval()
     at Microsoft.MetadirectoryServices.Scheduler.SchedulerSettingUtilities.get_C
  urrentSchedulerSettings()
     at SchedulerUtils.GetCurrentSchedulerSettings(SchedulerUtils* ,
  _ConfigAttrNode* pcanList, UInt32 ccanItems, Char** syncSettingsSerialized,
  Char** errorString) ---&gt; System.InvalidOperationException: System.Exception:
  Unexpected exception thrown. Action:
  ProvisioningWebServiceAdapter::GetCompanyConfiguration, Exception:  ---&gt;
  System.Runtime.InteropServices.COMException
     at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
  errorCode, IntPtr errorInfo)
     at System.Management.ManagementObject.Initialize(Boolean getObject)
     at System.Management.ManagementBaseObject.get_Properties()
     at System.Management.ManagementBaseObject.GetPropertyValue(String
  propertyName)
     at Microsoft.Online.DirSync.Common.PrerequisiteChecks.TryMachineIsDomainCont
  rollerCore()
     at Microsoft.Online.Coexistence.ProvisionHelper.IsMachineDomainController()
     at Microsoft.Online.Coexistence.ProvisionHelper.GenerateSyncToken()
     at Microsoft.Online.Coexistence.ProvisionHelper.OpenProxyConnection()
     at Microsoft.Online.Coexistence.ProvisionHelper.InvokeAwsAPI[T](Func`1
  awsOperation, String opsLabel)
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.&lt;&gt;c__DisplayClass1.&lt;GetCompanyConfiguration&gt;
  b__0()
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName, Action
  action)
     --- End of inner exception stack trace ---
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName, Action
  action)
     at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAda
  pter.ProvisioningWebServiceAdapter.GetCompanyConfiguration(Boolean
  includeLicenseInformation)
     at Microsoft.Azure.ActiveDirectory.Synchronization.AADConfig.get_CloudEnforc
  edSyncSchedulerInterval()
     at Microsoft.MetadirectoryServices.Scheduler.SchedulerSettingUtilities.get_C
  urrentSchedulerSettings()
     at SchedulerUtils.GetCurrentSchedulerSettings(SchedulerUtils* ,
  _ConfigAttrNode* pcanList, UInt32 ccanItems, Char** syncSettingsSerialized,
  Char** errorString)
     at Microsoft.DirectoryServices.MetadirectoryServices.UI.WebServices.MMSWebSe
  rvice.GetSchedulerSettings(String&amp; settingsDeserialized, String&amp; errorString)
     at Microsoft.IdentityManagement.PowerShell.Cmdlet.GetADSyncScheduler.Process
  Record()
     --- End of inner exception stack trace ---
     at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable
  input)
     at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork
  (Runspace rs, Boolean performSyncInvoke)
     at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndD
  oWork(Runspace rsToUse, Boolean isSync)
     at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](
  PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings
  settings)
     at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSData
  Collection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
     at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable
  input, PSDataCollection`1 output, PSInvocationSettings settings)
     at Microsoft.Online.Deployment.PowerShell.LocalPowerShell.Invoke()
     at Microsoft.Online.Deployment.PowerShell.PowerShellAdapter.TypeDependencies
  .InvokePowerShell(IPowerShell powerShell)
     at Microsoft.Online.Deployment.PowerShell.PowerShellAdapter.InvokePowerShell
  Command(String commandName, InitialSessionState initialSessionState,
  IDictionary`2 commandParameters, Boolean isScript)
     at Microsoft.Azure.ActiveDirectory.Synchronization.PowerShellConfigAdapter.S
  chedulerPowerShellAdapter.GetCurrentSchedulerSettings()
     at
  Microsoft.MetadirectoryServices.Scheduler.Scheduler.StartSyncCycle(String
  overridePolicy, Boolean interactiveMode)
     at SchedulerUtils.StartSyncCycle(SchedulerUtils* , Char* policyType, Int32
  interactiveMode, Char** errorString)
  At line:1 char:1
  + Start-ADSyncSyncCycle -PolicyType Initial
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : WriteError: (Microsoft.Ident...ADSyncSyncCycle:S
     tartADSyncSyncCycle) [Start-ADSyncSyncCycle], InvalidOperationException
      + FullyQualifiedErrorId : System.Management.Automation.CmdletInvocationExc
     eption: System.Exception: Unexpected exception thrown. Action: Provisionin
    gWebServiceAdapter::GetCompanyConfiguration, Exception:  ---&gt; System.Runti
   me.InteropServices.COMException
         at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(I
     nt32 errorCode, IntPtr errorInfo)
     at System.Management.ManagementObject.Initialize(Boolean getObject)
     at System.Management.ManagementBaseObject.get_Properties()
         at System.Management.ManagementBaseObject.GetPropertyValue(String prope
     rtyName)
         at Microsoft.Online.DirSync.Common.PrerequisiteChecks.TryMachineIsDomai
     nControllerCore()
         at Microsoft.Online.Coexistence.ProvisionHelper.IsMachineDomainControll
     er()
     at Microsoft.Online.Coexistence.ProvisionHelper.GenerateSyncToken()
     at Microsoft.Online.Coexistence.ProvisionHelper.OpenProxyConnection()
         at Microsoft.Online.Coexistence.ProvisionHelper.InvokeAwsAPI[T](Func`1
     awsOperation, String opsLabel)
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.&lt;&gt;c__DisplayClass1.&lt;GetCompanyConf
    iguration&gt;b__0()
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName
    , Action action)
     --- End of inner exception stack trace ---
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName
    , Action action)
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.GetCompanyConfiguration(Boolean in
    cludeLicenseInformation)
         at Microsoft.Azure.ActiveDirectory.Synchronization.AADConfig.get_CloudE
     nforcedSyncSchedulerInterval()
         at Microsoft.MetadirectoryServices.Scheduler.SchedulerSettingUtilities.
     get_CurrentSchedulerSettings()
         at SchedulerUtils.GetCurrentSchedulerSettings(SchedulerUtils* , _Config
     AttrNode* pcanList, UInt32 ccanItems, Char** syncSettingsSerialized, Char*
    * errorString) ---&gt; System.InvalidOperationException: System.Exception: Un
   expected exception thrown. Action: ProvisioningWebServiceAdapter::GetCompa
  nyConfiguration, Exception:  ---&gt; System.Runtime.InteropServices.COMExcept
  ion
         at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(I
     nt32 errorCode, IntPtr errorInfo)
     at System.Management.ManagementObject.Initialize(Boolean getObject)
     at System.Management.ManagementBaseObject.get_Properties()
         at System.Management.ManagementBaseObject.GetPropertyValue(String prope
     rtyName)
         at Microsoft.Online.DirSync.Common.PrerequisiteChecks.TryMachineIsDomai
     nControllerCore()
         at Microsoft.Online.Coexistence.ProvisionHelper.IsMachineDomainControll
     er()
     at Microsoft.Online.Coexistence.ProvisionHelper.GenerateSyncToken()
     at Microsoft.Online.Coexistence.ProvisionHelper.OpenProxyConnection()
         at Microsoft.Online.Coexistence.ProvisionHelper.InvokeAwsAPI[T](Func`1
     awsOperation, String opsLabel)
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.&lt;&gt;c__DisplayClass1.&lt;GetCompanyConf
    iguration&gt;b__0()
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName
    , Action action)
     --- End of inner exception stack trace ---
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.ExecuteWithRetry(String actionName
    , Action action)
         at Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServi
     ceAdapter.ProvisioningWebServiceAdapter.GetCompanyConfiguration(Boolean in
    cludeLicenseInformation)
         at Microsoft.Azure.ActiveDirectory.Synchronization.AADConfig.get_CloudE
     nforcedSyncSchedulerInterval()
         at Microsoft.MetadirectoryServices.Scheduler.SchedulerSettingUtilities.
     get_CurrentSchedulerSettings()
         at SchedulerUtils.GetCurrentSchedulerSettings(SchedulerUtils* , _Config
     AttrNode* pcanList, UInt32 ccanItems, Char** syncSettingsSerialized, Char*
    * errorString)
         at Microsoft.DirectoryServices.MetadirectoryServices.UI.WebServices.MMS
     WebService.GetSchedulerSettings(String&amp; settingsDeserialized, String&amp; erro
    rString)
         at Microsoft.IdentityManagement.PowerShell.Cmdlet.GetADSyncScheduler.Pr
     ocessRecord()
     --- End of inner exception stack trace ---
         at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerab
     le input)
         at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndD
     oWork(Runspace rs, Boolean performSyncInvoke)
         at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeede
     dAndDoWork(Runspace rsToUse, Boolean isSync)
         at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOut
     put](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSett
    ings settings)
         at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](P
     SDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings s
    ettings)
         at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumera
     ble input, PSDataCollection`1 output, PSInvocationSettings settings)
     at Microsoft.Online.Deployment.PowerShell.LocalPowerShell.Invoke()
         at Microsoft.Online.Deployment.PowerShell.PowerShellAdapter.TypeDepende
     ncies.InvokePowerShell(IPowerShell powerShell)
         at Microsoft.Online.Deployment.PowerShell.PowerShellAdapter.InvokePower
     ShellCommand(String commandName, InitialSessionState initialSessionState,
    IDictionary`2 commandParameters, Boolean isScript)
         at Microsoft.Azure.ActiveDirectory.Synchronization.PowerShellConfigAdap
     ter.SchedulerPowerShellAdapter.GetCurrentSchedulerSettings()
         at Microsoft.MetadirectoryServices.Scheduler.Scheduler.StartSyncCycle(S
     tring overridePolicy, Boolean interactiveMode)
         at SchedulerUtils.StartSyncCycle(SchedulerUtils* , Char* policyType, In
     t32 interactiveMode, Char** errorString),Microsoft.IdentityManagement.Powe
    rShell.Cmdlet.StartADSyncSyncCycle
  
  PS C:\Users\Administrator.DOMAIN&gt;
  </code></pre>