Unable to use anyidentity template - Could not load file or assembly Microsoft.Management.Infrastructure

Unable to use anyidentity template - Could not load file or assembly Microsoft.Management.Infrastructure

avatar

Hello, i am trying to scan local account using AnyIdenty provider using template from GitHub (PAM-Providers/Providers/Windows Accounts/Windows Local Accounts.json at master · Devolutions/PAM-Providers (github.com))

When i run a scan i allways end up with an error, see below. But when i take the PWS script for discovery and i run it locally on the DVLS Server it works fine.

Error:

FileNotFoundException - Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

at System.Reflection.RuntimeAssembly.GetExportedTypes()
at System.Management.Automation.Runspaces.PSSnapInHelpers.GetAssemblyTypes(Assembly assembly, String name)
at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection(Assembly assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, String helpFile, Dictionary`2& cmdlets, Dictionary`2& aliases, Dictionary`2& providers)
at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzePSSnapInAssembly(Assembly assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Dictionary`2& cmdlets, Dictionary`2& aliases, Dictionary`2& providers, String& helpFile)
at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning)
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()
at Devolutions.Server.Powershell.PowershellScriptRunner.Run()
at Devolutions.Server.Powershell.PowershellScriptBuilder.Build(PamProviderCommand providerCommand, PSRemotingCredential credential)
at Devolutions.Server.NetworkDiscovery.Jobs.CustomAccountDiscoveryJob.Run(List`1 inventoryObjects)

Any help would be appreciated!!!!

All Comments (5)

avatar

Hello,

I'm sorry to hear that and will try to help you with that. Could you provide us those information :

  • OS Version where DVLS is running
  • DVLS Version
  • .NET version installed
  • PowerShell versions installed (most likely Windows PowerShell 5.1 by default), but do you also have PowerShell 7 ?
  • Do you have extra PowerShell module that could be loaded automatically ?
  • Does PS Remoting enable or not ?


Best regards,

François Dubois

avatar

Hello François,

Responses in bold:

  • OS Version where DVLS is running WINDOWS 2022
  • DVLS Version 2023.3.17
  • .NET version installed 4.8
  • PowerShell versions installed (most likely Windows PowerShell 5.1 by default), but do you also have PowerShell 7 ? Only 5.1
  • Do you have extra PowerShell module that could be loaded automatically ? No
  • Does PS Remoting enable or not ? Yes. (The AnyIdentity PWS script works fine from command line in pwsh5.1)


avatar

Hello,

Just to let you know that we have seen your answer and thank you for it, but we are still trying to figure out what could be the issue. We suspect that it doesn't work since it try to load a different version of a dll already used by Devolutions Server. I have already seen that and to fix that, I forced to run the script with a different context (RunAs) and everything was working. You could try that if it could unblock you, but we will let you know if we can find a better solution.

Best regards,

François Dubois

avatar

So it would be related to the context of the scheduler service account?

avatar

Hello,

I don't think so, but it could be related. We don't really understand why you have this issue when we can't reproduce it. As workaround, could you try to fill the Run as section to be able to run the script in a separate context ? I think it would avoid the issue, but not sure why you have it though.



Best regards,

François Dubois

98fdcd72-1a5a-4669-9ed9-10c7f1696444.png