Hello,
I’m trying to interrogate a user on AD by using the activity Invoke Power Shell but without any luck. If I try to apply this command under PowerShell directly it will work (after I import or will auto-import once it hits the Get-ADUSER ) without any issue.
I’ve tried to following command on
Get-ADUser -filter {employeeid -eq 0000} -Properties * | Select employeeid, mail
The error that I get is (I deleted most of the lines because each cmdlet has the same response. you get the point):
System.Management.Automation.CommandNotFoundException: The ‘Get-ADUser’ command was found in the module ‘ActiveDirectory’, but the module could not be loaded. For more information, run ‘Import-Module ActiveDirectory’. —> System.Management.Automation.CmdletInvocationException: The following error occurred while loading the extended type data file:
Error in TypeData “Microsoft.ActiveDirectory.Management.ADAuthenticationPolicySilo”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
Error in TypeData “Microsoft.ActiveDirectory.Management.ADAuthenticationPolicy”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
Error in TypeData “Microsoft.ActiveDirectory.Management.ADClaimTransformPolicy”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
Error in TypeData “Microsoft.ActiveDirectory.Management.ADTrust”: Type
.
.
.
“Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
at System.Management.Automation.Runspaces.InitialSessionState.ThrowTypeOrFormatErrors(String resourceString, String errorMsg, String errorId)
at System.Management.Automation.Runspaces.InitialSessionState.UpdateTypes(ExecutionContext context, Boolean updateOnly)
at System.Management.Automation.Runspaces.InitialSessionState.Bind_UpdateTypes(ExecutionContext context, Boolean updateOnly)
at System.Management.Automation.Runspaces.InitialSessionState.<>c__DisplayClass129_0.b__0()
at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local, Boolean setLocation)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors) --- End of inner exception stack trace --- at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.Runspaces.Pipeline.Invoke() at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection
1 input, PSDataCollection1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection
1 input, PSDataCollection1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList
1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.InvokeT
at System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, Exception& exception)
— End of inner exception stack trace —
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
If I follow the first line from the error output and add in my command line the Import-Module ActiveDirectory which looks like this:
“Import-Module ActiveDirectory;Get-ADUser -filter {employeeid -eq 0000} -Properties * | Select employeeid, mail”
It will give me the following output
Source: Invoke Power Shell (Throw)
Message: The following error occurred while loading the extended type data file:
Error in TypeData “Microsoft.ActiveDirectory.Management.ADAuthenticationPolicySilo”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
Error in TypeData “Microsoft.ActiveDirectory.Management.ADAuthenticationPolicy”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
.
.
.
Error in TypeData “Microsoft.ActiveDirectory.Management.ADEntity”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
Exception Type: System.Management.Automation.CmdletInvocationException
System.Management.Automation.CmdletInvocationException: The following error occurred while loading the extended type data file:
Error in TypeData “Microsoft.ActiveDirectory.Management.ADAuthenticationPolicySilo”: Type “Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
“Microsoft.ActiveDirectory.Management.ADEntityAdapter” should be a PSPropertyAdapter.
at System.Management.Automation.Runspaces.InitialSessionState.ThrowTypeOrFormatErrors(String resourceString, String errorMsg, String errorId)
at System.Management.Automation.Runspaces.InitialSessionState.UpdateTypes(ExecutionContext context, Boolean updateOnly)
at System.Management.Automation.Runspaces.InitialSessionState.Bind_UpdateTypes(ExecutionContext context, Boolean updateOnly)
at System.Management.Automation.Runspaces.InitialSessionState.<>c__DisplayClass129_0.b__0()
at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local, Boolean setLocation)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)
— End of inner exception stack trace —
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
So mainly the same output as the first command but without The ‘Get-ADUser’ command was found in the module ‘ActiveDirectory’, but the module could not be loaded.
The strange fact is that on Windows-Legacy is working but as I understood, this one opens the x86 as the Windows opens the 64bit.
The difference that saw that x86 doesn’t import any module (which is strange) and it works.
The 64bit import some built-in (I guess) module la PSReadLine.
At this point I’m stuck and I don’t know how this can be resolved. I’ve done a lot of digging over the internet and it seems that many people are facing this issue but without any fix.
The only fix that I managed to find was related to .NET Framework 4.0 that was reinstalled, but that was like 8years ago (something like that).
I’ve tried creating a profile, making a script, reinstalling RSAT AD, modifying the ExecutionPolicy, running with admin credentials, tried to Auto import modifying the powershell variable $PSModuleAutoLoadingPreference, upgrading .NET Framework to 4.8 from 4.5, I’ve tried even to modify the module (clearly not a smart move, but I had to try)
from ADEntityAdapter to PSPropertyAdapter because the error says … should be should be a PSPropertyAdapter. even so the TypeArgument in Properties for the Invoke PowerShell is set to System.Management.Automation.PSPropertyAdapter. Absolutely nothing worked.
Can someone please tell me what am I doing wrong on the Windows project?
Thanks,
Daniel