Skip to content

Import-Module PKI fails with ARM64 powershell core 7.2.5 on ARM64 Windows 11 22H2 #17814

@mcfi

Description

@mcfi

Prerequisites

Steps to reproduce

  1. Download ARM64 powershell core 7.2.5 on ARM64 Windows 11 22H2 (22621)
  2. Launch pwsh.exe and type "Import-Module PKI"
  3. Observe this failure message: "Import-Module: Could not load file or assembly 'Microsoft.CertificateServices.PKIClient.Cmdlets, Culture=neutral, PublicKeyToken=null'. Format of the executable (.exe) or library (.dll) is invalid."

Expected behavior

No error.

Actual behavior

Import-Module: Could not load file or assembly 'Microsoft.CertificateServices.PKIClient.Cmdlets, Culture=neutral, PublicKeyToken=null'. Format of the executable (.exe) or library (.dll) is invalid.

Error details

Exception             :
    Type           : System.BadImageFormatException
    Message        : Could not load file or assembly 'Microsoft.CertificateServices.PKIClient.Cmdlets, Culture=neutral, PublicKeyToken=null'. Format of the executable
(.exe) or library (.dll) is invalid.
    FileName       : Microsoft.CertificateServices.PKIClient.Cmdlets, Culture=neutral, PublicKeyToken=null
    TargetSite     :
        Name          : LoadBinaryModule
        DeclaringType : Microsoft.PowerShell.Commands.ModuleCmdletBase
        MemberType    : Method
        Module        : System.Management.Automation.dll
    InnerException :
        Type       : System.BadImageFormatException
        Message    : Could not load file or assembly 'C:\WINDOWS\Microsoft.NET\assembly\GAC_64\Microsoft.CertificateServices.PKIClient.Cmdlets\v4.0_10.0.0.0__31bf3856a
d364e35\Microsoft.CertificateServices.PKIClient.Cmdlets.dll'. Format of the executable (.exe) or library (.dll) is invalid.
        FileName   : C:\WINDOWS\Microsoft.NET\assembly\GAC_64\Microsoft.CertificateServices.PKIClient.Cmdlets\v4.0_10.0.0.0__31bf3856ad364e35\Microsoft.Certificate
Services.PKIClient.Cmdlets.dll
        TargetSite :
            Name          : LoadFromPath
            DeclaringType : System.Runtime.Loader.AssemblyLoadContext
            MemberType    : Method
            Module        : System.Private.CoreLib.dll
        Source     : System.Private.CoreLib
        HResult    : -2147024703
        StackTrace :
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Management.Automation.PowerShellAssemblyLoadContext.Resolve(AssemblyLoadContext loadContext, AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
    Source         : System.Management.Automation
    HResult        : -2147024703
    StackTrace     :
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, String moduleName, String fileName, Assembly assemblyToLoad, String
moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats,
Boolean& found, String shortModuleName, Boolean disableFormatUpdates)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(PSModuleInfo parentModule, ModuleSpecification moduleSpecification, String moduleBase,
Boolean searchModulePath, String prefix, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Boolean loadTypes, Boolean
loadFormats, Object privateData, Boolean& found, String shortModuleName, Nullable`1 manifestLanguageMode)
   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)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object
privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingExtensions(PSModuleInfo parentModule, String moduleName, String fileBaseName, String extension, String
moduleBase, String prefix, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingModulePath(PSModuleInfo parentModule, Boolean found, IEnumerable`1 modulePath, String name, SessionState
ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, PSModuleInfo& module)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions importModuleOptions, String name)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand
InvocationInfo        :
    MyCommand        : Import-Module
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 5
    Line             : Import-Module PKI
    PositionMessage  : At line:1 char:1
                       + Import-Module PKI
                       + ~~~~~~~~~~~~~~~~~
    InvocationName   : Import-Module
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.25173
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions