Skip to content

Get-CimInstance fails on Win7-x86 when run on Win 7 #2777

Closed

Description

This issue only appears when the Win7-x86 version of PowerShell Core is run on Windows 7. Windows 8 and later properly handle the situation. The problem is that the OS is not properly identifying the API set that contains GetCurrentThread(). Microsoft.Management.Infrastructure.Native.dll lists api-ms-win-core-processthreads-l1-1-2.dll as a dependency and this is properly resolved in most versions of Windows. On Win 7, it doesn't resolve it to either kernel32 or api-ms-win-core-processthreads-l1-1-0.dll (the API set that exports the function).

A workaround is to copy C:\windows\system32\api-ms-win-core-processthreads-l1-1-0.dll to c:\windows\system32\api-ms-win-core-processthreads-l1-1-2.dll. This will enable the DLL loader to resolve the DLL by name.

Steps to reproduce

  1. Install the 6.0.0-alpha.13 win7-x86 MSI on a Win 7 x86 VM
  2. Start PowerShell Core
  3. Get-CimInstance Win32_ComputerSystem

Expected behavior

It returns the Win32_ComputerSystem object

Actual behavior

PS C:\Windows\system32> get-ciminstance win32_computersystem
get-ciminstance : Unable to find an entry point named 'GetCurrentThread' in DLL 'api-ms-win-core-processthreads-l1-1-2.dll'.
At line:1 char:1

  • get-ciminstance win32_computersystem
  •   + CategoryInfo          : NotSpecified: (root\cimv2:win32_computersystem:String) [Get-CimInstance], EntryPointNotFoundException
      + FullyQualifiedErrorId : CimCmdlet_EntryPointNotFoundException,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
    
    

PS C:\Windows\system32> $error[0] | fl * -force

writeErrorStream : True
PSMessageDetails :
OriginInfo :
Exception : System.EntryPointNotFoundException: Unable to find an entry point named 'GetCurrentThread' in DLL
'api-ms-win-core-processthreads-l1-1-2.dll'.
at GetCurrentThread()
at Microsoft.Management.Infrastructure.Native.OperationHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalDispose()
at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
at System.Runtime.InteropServices.SafeHandle.Dispose()
at Microsoft.Management.Infrastructure.Internal.Operations.CimOperation.Dispose(Boolean disposing)
at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncCallbacksReceiverBase.DisposeOperationWhenPossibleWorker(CimOperation cimOperation)
at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncCallbacksReceiverBase.InvokeWhenOperationIsSet(Action1 action) at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncCallbacksReceiverBase.DisposeOperationWhenPossible() at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase1.ProcessNativeCallback(OperationCallbackProcessingContext callbackProcessingContext, T currentItem, Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)
at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncInstanceObserverProxy.InstanceResultCallback(OperationCallbackProcessingContextcallbackProcessingContext, OperationHandle operationHandle, InstanceHandle instanceHandle, Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)
at Microsoft.Management.Infrastructure.Native.ExceptionSafeInstanceResultCallback.InvokeUserCallback()
at Microsoft.Management.Infrastructure.Native.OperationCallbacks.InvokeWithUserFilteredExceptionHandler(Action tryBody, Func2 userFilter, Action1 catchBody)
TargetObject : root\cimv2:win32_computersystem
CategoryInfo : NotSpecified: (root\cimv2:win32_computersystem:String)[Get-CimInstance], EntryPointNotFoundException
FullyQualifiedErrorId : CimCmdlet_EntryPointNotFoundException,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at , : line 1
PipelineIterationInfo : {0, 1}

Environment data

6.0.0-alpha.13

Activity

  1. added
    WG-Maintainers-Build
    WG-Cmdlets
    Issue-Bug
    on Nov 23, 2016
  2. MRhoades-Brown-CTL commented on Jul 17, 2017

    @MRhoades-Brown-CTL

    Hi,

    I also get this issue with Windows 7 x64 and the latest version:

    PS C:\Program Files\PowerShell\6.0.0-alpha.18> $env:PROCESSOR_ARCHITECTURE
    AMD64
    PS C:\Program Files\PowerShell\6.0.0-alpha.18> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    CLRVersion
    WSManStackVersion              3.0
    BuildVersion                   3.0.0.0
    GitCommitId                    v6.0.0-alpha.18
    SerializationVersion           1.1.0.1
    PSRemotingProtocolVersion      2.3
    PSEdition                      Core
    PSVersion                      6.0.0-alpha
    
    
    PS C:\Program Files\PowerShell\6.0.0-alpha.18> Get-CimInstance -ClassName Win32_OperatingSystem
    Get-CimInstance : Unable to find an entry point named 'GetCurrentThread' in DLL 'api-ms-win-core-processthreads-l1-1-2.dll'.
    At line:1 char:1
    + Get-CimInstance -ClassName Win32_OperatingSystem
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (root\cimv2:Win32_OperatingSystem:String) [Get-CimInstance], EntryPointNotFoundException
        + FullyQualifiedErrorId : CimCmdlet_EntryPointNotFoundException,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
    
    PS C:\Program Files\PowerShell\6.0.0-alpha.18> $Error[0] | fl * -Force
    
    
    writeErrorStream      : True
    PSMessageDetails      :
    OriginInfo            :
    Exception             : System.EntryPointNotFoundException: Unable to find an entry point named 'GetCurrentThread' in DLL 'api-ms-win-core-processthreads-l1-1-2.dll'.
                               at GetCurrentThread()
                               at Microsoft.Management.Infrastructure.Native.OperationHandle.ReleaseHandle()
                               at System.Runtime.InteropServices.SafeHandle.InternalDispose()
                               at Microsoft.Management.Infrastructure.Internal.Operations.CimOperation.Dispose(Boolean disposing)
                               at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncCallbacksReceiverBase.DisposeOperationWhenPossibleWorker(CimOperation cimOperation)
                               at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncCallbacksReceiverBase.InvokeWhenOperationIsSet(Action`1 action)
                               at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase`1.ProcessNativeCallback(OperationCallbackProcessingContext
                            callbackProcessingContext, T currentItem, Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)
                               at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncInstanceObserverProxy.InstanceResultCallback(OperationCallbackProcessingContext
                            callbackProcessingContext, OperationHandle operationHandle, InstanceHandle instanceHandle, Boolean moreResults, MiResult operationResult, String errorMessage,
                            InstanceHandle errorDetailsHandle)
                               at Microsoft.Management.Infrastructure.Native.ExceptionSafeInstanceResultCallback.InvokeUserCallback()
                               at Microsoft.Management.Infrastructure.Native.OperationCallbacks.InvokeWithUserFilteredExceptionHandler(Action tryBody, Func`2 userFilter, Action`1 catchBody)
    TargetObject          : root\cimv2:Win32_OperatingSystem
    CategoryInfo          : NotSpecified: (root\cimv2:Win32_OperatingSystem:String) [Get-CimInstance], EntryPointNotFoundException
    FullyQualifiedErrorId : CimCmdlet_EntryPointNotFoundException,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
    ErrorDetails          :
    InvocationInfo        : System.Management.Automation.InvocationInfo
    ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    PipelineIterationInfo : {0, 1}
    
  3. added this to the milestone on Sep 19, 2017
  4. modified the milestones: , 6.0.0-RC on Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugResolution-FixedWG-CmdletsWG-Maintainers-Build

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions