Repository navigation
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
- Install the 6.0.0-alpha.13 win7-x86 MSI on a Win 7 x86 VM
- Start PowerShell Core
- 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
MRhoades-Brown-CTL commentedon Jul 17, 2017
Hi,
I also get this issue with Windows 7 x64 and the latest version:
adityapatwardhan commentedon Nov 10, 2017
Fixed by releasing https://powershell.myget.org/feed/powershell-core/package/nuget/Microsoft.Management.Infrastructure/1.0.0-alpha07