Import-Module ADSync error - could not load a dll or one of its dependencies

Betty Stolwyk 70 Reputation points
2023-03-30T03:45:15.0633333+00:00

I get the following error trying to import the ADSYNC module in powershell:

Could not load file or assembly 'file:///C:\Program Files\Microsoft Azure AD Sync\Bin*Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAdapter.dll*' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I have verified that the above mentioned dll does indeed exist in the specified folder.

I cannot figure out how to update/reload the powershell module. It does not exist in the PSGallery repository. I suppose it was magically loaded when I installed the ADConnect software. I believe I had loaded and worked with the module with no problems at one time.

This is on a Windows 2019 Server VM, release 1809.

Powershell version 5.1.17763.3770

import-module adsync -Verbose

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\ClientConfiguration.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Azure.ActiveDirectory.ADSyncManagement.Client.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Azure.ActiveDirectory.ADSyncManagement.Contract.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Online.Coexistence.Provision.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Online.Coexistence.Schema.Ex.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Online.Coexistence.Security.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Online.DirSync.Common.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Online.DirSync.ResAgent.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\Microsoft.Online.DirSync.Resources.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\UiUtils.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.Azure.ActiveDirectory.Synchronization.Framework.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAdapter.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.CredentialManagement.OnPremisesPasswordReset.Library.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.CredentialManagement.OnPremisesPasswordReset.Shared.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.IdentityModel.Clients.ActiveDirectory.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.Online.Deployment.Client.Framework.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.Online.PasswordSynchronization.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.Online.PasswordSynchronization.Rpc.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.ServiceBus.dll'.

VERBOSE: Loading 'Assembly' from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\OnPremisesPasswordReset.Security.Cryptography.dll'.

VERBOSE: Loading module from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\adsync\adsync.psd1'.

import-module : Could not load file or assembly 'file:///C:\Program Files\Microsoft Azure AD Sync\Bin\Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAdapter.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

Accepted answer
  1. Sandeep G-MSFT 20,906 Reputation points Microsoft Employee Moderator
    2023-04-12T03:42:13.6566667+00:00

    @Betty Stolwyk

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "[The question author cannot accept their own answer. They can only accept answers by others] (https://docs.microsoft.com/en-us/answers/support/accepted-answers#why-only-one-accepted-answer)", I'll repost your solution in case you'd like to "[Accept] (https://docs.microsoft.com/en-us/answers/support/accepted-answers#accepted-answer-in-a-question-thread)" the answer.

    You updated the PowerShellGet module. The machine that ADConnect was installed on still had PowerShellGet 1.0.0.1. The updated version was 2.2.5. You also installed the ExchangeOnlineManagement powershell module. Here is the PowerShellGet update command you ran: Install-Module PowerShellGet -Force -AllowClobber An import-module executes successfully now.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    2 people found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. Ryan Shoemaker 15 Reputation points
    2023-09-06T17:56:05.4366667+00:00

    For anyone else running into this, I found the issue to be when running the (x86) version of powershell is not compatible with the ADSync module. Check your shortcuts that you're using to open powershell. You can use the command:

    [Environment]::Is64BitProcess
    

    to check if you're running a 64 bit version of Powershell. If it returns false, ADSync commands won't work.

    User's image

    I hope this helps!

    3 people found this answer helpful.
    0 comments No comments

  2. Limitless Technology 44,751 Reputation points
    2023-03-30T11:29:06.1666667+00:00

    Hello there,

    Do you have the Connector installed?

    Usually, by installing the connector, all prerequisites get installed as well.

    1. Install Azure Active Directory Connect
    2. Import the ADSync PowerShell module
    3. Run the Start-AdSyncSchedule cmdlet with reads a domain controller’s password hashes and syncs with Azure AD.

    You have to run or invoke that on the same machine where the Azure AD - Connector is installed.

    https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sync-feature-scheduler

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  3. Betty Stolwyk 70 Reputation points
    2023-04-11T23:02:32.8466667+00:00

    So, it's working now. I updated the PowerShellGet module and I think that's what did it. the machine that ADConnect was installed on still had PowerShellGet 1.0.0.1. The updated version was 2.2.5. I can't say for sure that is what fixed things because I also installed the ExchangeOnlineManagement powershell module, but I don't see what that would have to do with the ADConnect module. Anyway here is the PowerShellGet update command I ran: Install-Module PowerShellGet -Force -AllowClobber An import-module executes successfully now: Import-Module -Name adsync -verbose VERBOSE: Loading module from path 'C:\Program Files\Microsoft Azure AD Sync\Bin\adsync\adsync.psd1'.

    VERBOSE: Importing cmdlet 'Add-ADSyncAADServiceAccount'.
    VERBOSE: Importing cmdlet 'Add-ADSyncADDSConnectorAccount'.
    VERBOSE: Importing cmdlet 'Add-ADSyncAttributeFlowMapping'.
    VERBOSE: Importing cmdlet 'Add-ADSyncConnector'.
    VERBOSE: Importing cmdlet 'Add-ADSyncConnectorAnchorConstructionSettings'.
    VERBOSE: Importing cmdlet 'Add-ADSyncConnectorAttributeInclusion'.
    VERBOSE: Importing cmdlet 'Add-ADSyncConnectorHierarchyProvisioningMapping'.
    VERBOSE: Importing cmdlet 'Add-ADSyncConnectorObjectInclusion'.
    VERBOSE: Importing cmdlet 'Add-ADSyncGlobalSettingsParameter'.
    VERBOSE: Importing cmdlet 'Add-ADSyncJoinConditionGroup'.
    VERBOSE: Importing cmdlet 'Add-ADSyncRule'.
    VERBOSE: Importing cmdlet 'Add-ADSyncRunProfile'.
    VERBOSE: Importing cmdlet 'Add-ADSyncRunStep'.
    VERBOSE: Importing cmdlet 'Add-ADSyncScopeConditionGroup'.
    VERBOSE: Importing cmdlet 'Add-AgentToResourceGroup'.
    VERBOSE: Importing cmdlet 'Clear-ADSyncRuleAudit'.
    VERBOSE: Importing cmdlet 'Disable-ADSyncConnectorPartition'.
    VERBOSE: Importing cmdlet 'Disable-ADSyncConnectorPartitionHierarchy'.
    VERBOSE: Importing cmdlet 'Disable-ADSyncExportDeletionThreshold'.
    VERBOSE: Importing cmdlet 'Enable-ADSyncConnectorPartition'.
    VERBOSE: Importing cmdlet 'Enable-ADSyncConnectorPartitionHierarchy'.
    VERBOSE: Importing cmdlet 'Enable-ADSyncExportDeletionThreshold'.
    VERBOSE: Importing cmdlet 'Get-ADSyncAADCompanyFeature'.
    VERBOSE: Importing cmdlet 'Get-ADSyncAADPasswordResetConfiguration'.
    VERBOSE: Importing cmdlet 'Get-ADSyncAADPasswordSyncConfiguration'.
    VERBOSE: Importing cmdlet 'Get-ADSyncADConnectorSchemaDsml'.
    VERBOSE: Importing cmdlet 'Get-ADSyncAutoUpgrade'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnector'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorHierarchyProvisioningDNComponent'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorHierarchyProvisioningMapping'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorHierarchyProvisioningObjectClass'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorParameter'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorPartition'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorPartitionHierarchy'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorRunStatus'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorStatistics'.
    VERBOSE: Importing cmdlet 'Get-ADSyncConnectorTypes'.
    VERBOSE: Importing cmdlet 'Get-ADSyncCSGroupStatistics'.
    VERBOSE: Importing cmdlet 'Get-ADSyncCSGroupSummary'.
    VERBOSE: Importing cmdlet 'Get-ADSyncCSObject'.
    VERBOSE: Importing cmdlet 'Get-ADSyncCSObjectLog'.
    VERBOSE: Importing cmdlet 'Get-ADSyncCSObjectReferences'.
    VERBOSE: Importing cmdlet 'Get-ADSyncDatabaseConfiguration'.
    VERBOSE: Importing cmdlet 'Get-ADSyncDomainReachabilityStatus'.
    VERBOSE: Importing cmdlet 'Get-ADSyncExportDeletionThreshold'.
    VERBOSE: Importing cmdlet 'Get-ADSyncGlobalSettings'.
    VERBOSE: Importing cmdlet 'Get-ADSyncGlobalSettingsParameter'.
    VERBOSE: Importing cmdlet 'Get-ADSyncMVObject'.
    VERBOSE: Importing cmdlet 'Get-ADSyncPartitionPasswordSyncState'.
    VERBOSE: Importing cmdlet 'Get-ADSyncRule'.
    VERBOSE: Importing cmdlet 'Get-ADSyncRuleAudit'.
    VERBOSE: Importing cmdlet 'Get-ADSyncRunProfileResult'.
    VERBOSE: Importing cmdlet 'Get-ADSyncRunStepResult'.
    VERBOSE: Importing cmdlet 'Get-ADSyncScheduler'.
    VERBOSE: Importing cmdlet 'Get-ADSyncSchedulerConnectorOverride'.
    VERBOSE: Importing cmdlet 'Get-ADSyncSchema'.
    VERBOSE: Importing cmdlet 'Get-ADSyncServerConfiguration'.
    VERBOSE: Importing cmdlet 'Invoke-ADSyncCSObjectPasswordHashSync'.
    VERBOSE: Importing cmdlet 'Invoke-ADSyncGarbageCollection'.
    VERBOSE: Importing cmdlet 'Invoke-ADSyncRunProfile'.
    VERBOSE: Importing cmdlet 'Invoke-ADSyncSpecificObjectRunProfile'.
    VERBOSE: Importing cmdlet 'New-ADSyncConnector'.
    VERBOSE: Importing cmdlet 'New-ADSyncJoinCondition'.
    VERBOSE: Importing cmdlet 'New-ADSyncRule'.
    VERBOSE: Importing cmdlet 'New-ADSyncRunProfile'.
    VERBOSE: Importing cmdlet 'New-ADSyncScopeCondition'.
    VERBOSE: Importing cmdlet 'Register-Agent'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncAADPasswordResetConfiguration'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncAADPasswordSyncConfiguration'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncAADServiceAccount'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncAttributeFlowMapping'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncConnector'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncConnectorAnchorConstructionSettings'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncConnectorAttributeInclusion'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncConnectorHierarchyProvisioningMapping'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncConnectorObjectInclusion'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncCSObject'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncGlobalSettingsParameter'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncJoinConditionGroup'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncRule'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncRunProfile'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncRunStep'.
    VERBOSE: Importing cmdlet 'Remove-ADSyncScopeConditionGroup'.
    VERBOSE: Importing cmdlet 'Search-ADSyncDirectoryObjects'.
    VERBOSE: Importing cmdlet 'Set-ADSyncAADCompanyFeature'.
    VERBOSE: Importing cmdlet 'Set-ADSyncAADPasswordResetConfiguration'.
    VERBOSE: Importing cmdlet 'Set-ADSyncAADPasswordSyncConfiguration'.
    VERBOSE: Importing cmdlet 'Set-ADSyncAADPasswordSyncState'.
    VERBOSE: Importing cmdlet 'Set-ADSyncAutoUpgrade'.
    VERBOSE: Importing cmdlet 'Set-ADSyncConnectorOrder'.
    VERBOSE: Importing cmdlet 'Set-ADSyncConnectorParameter'.
    VERBOSE: Importing cmdlet 'Set-ADSyncDirSyncConfiguration'.
    VERBOSE: Importing cmdlet 'Set-ADSyncGlobalSettings'.
    VERBOSE: Importing cmdlet 'Set-ADSyncScheduler'.
    VERBOSE: Importing cmdlet 'Set-ADSyncSchedulerConnectorOverride'.
    VERBOSE: Importing cmdlet 'Set-ADSyncSchema'.
    VERBOSE: Importing cmdlet 'Set-ADSyncServerConfiguration'.
    VERBOSE: Importing cmdlet 'Set-MIISADMAConfiguration'.
    VERBOSE: Importing cmdlet 'Start-ADSyncAADPasswordResetEndpoint'.
    VERBOSE: Importing cmdlet 'Start-ADSyncPurgeRunHistory'.
    VERBOSE: Importing cmdlet 'Start-ADSyncSyncCycle'.
    VERBOSE: Importing cmdlet 'Stop-ADSyncAADPasswordResetEndpoint'.
    VERBOSE: Importing cmdlet 'Stop-ADSyncRunProfile'.
    VERBOSE: Importing cmdlet 'Stop-ADSyncSyncCycle'.
    VERBOSE: Importing cmdlet 'Sync-ADSyncCSObject'.
    VERBOSE: Importing cmdlet 'Test-ADSyncADDSConnectivity'.
    VERBOSE: Importing cmdlet 'Test-AdSyncAzureServiceConnectivity'.
    VERBOSE: Importing cmdlet 'Test-ADSyncGetDirectoryReplicationChanges'.
    VERBOSE: Importing cmdlet 'Test-AdSyncUserHasPermissions'.
    VERBOSE: Importing cmdlet 'Update-ADSyncAADPasswordResetClientVersion'.
    VERBOSE: Importing cmdlet 'Update-ADSyncAADPasswordResetConfiguration'.
    VERBOSE: Importing cmdlet 'Update-ADSyncConnectorOrder'.
    VERBOSE: Importing cmdlet 'Update-ADSyncConnectorPartitions'.
    VERBOSE: Importing cmdlet 'Update-ADSyncConnectorSchema'.
    VERBOSE: Importing cmdlet 'Update-ADSyncDirectoryObject'.
    VERBOSE: Importing cmdlet 'Update-ADSyncDRSCertificates'.
    VERBOSE: Importing cmdlet 'Update-ADSyncServicePrincipalCertificate'.

    0 comments No comments

  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.