Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 无法从32位进程访问Win32_WinSAT_Powershell_Wmi_Wmi Query - Fatal编程技术网

Powershell 无法从32位进程访问Win32_WinSAT

Powershell 无法从32位进程访问Win32_WinSAT,powershell,wmi,wmi-query,Powershell,Wmi,Wmi Query,从x64进程请求Win32_WinSAT时,我得到正确的结果(WinSatassementState=1),但从x86进程执行时,我得到“结果不可用”(WinSatassementState=3) x64 Powershell: PS C:\Users\alive> gwmi Win32_WinSAT __GENUS : 2 __CLASS : Win32_WinSAT __SUPERCLASS : __DYNA

从x64进程请求Win32_WinSAT时,我得到正确的结果(WinSatassementState=1),但从x86进程执行时,我得到“结果不可用”(WinSatassementState=3)

x64 Powershell:

PS C:\Users\alive> gwmi Win32_WinSAT


__GENUS               : 2
__CLASS               : Win32_WinSAT
__SUPERCLASS          :
__DYNASTY             : Win32_WinSAT
__RELPATH             : Win32_WinSAT.TimeTaken="MostRecentAssessment"
__PROPERTY_COUNT      : 8
__DERIVATION          : {}
__SERVER              : COMPNAME
__NAMESPACE           : root\cimv2
__PATH                : \\COMPNAME\root\cimv2:Win32_WinSAT.TimeTaken="MostRecentAssessment"
CPUScore              : 7,2
D3DScore              : 6,3
DiskScore             : 7,65
GraphicsScore         : 4,6
MemoryScore           : 5,9
TimeTaken             : MostRecentAssessment
WinSATAssessmentState : 1
WinSPRLevel           : 4,6
PSComputerName        : COMPNAME
x86 Powershell

PS C:\Users\alive> gwmi Win32_WinSAT


__GENUS               : 2
__CLASS               : Win32_WinSAT
__SUPERCLASS          :
__DYNASTY             : Win32_WinSAT
__RELPATH             : Win32_WinSAT.TimeTaken="MostRecentAssessment"
__PROPERTY_COUNT      : 8
__DERIVATION          : {}
__SERVER              : COMPNAME
__NAMESPACE           : root\cimv2
__PATH                : \\COMPNAME\root\cimv2:Win32_WinSAT.TimeTaken="MostRecentAssessment"
CPUScore              : 0
D3DScore              : 0
DiskScore             : 0
GraphicsScore         : 0
MemoryScore           : 0
TimeTaken             : MostRecentAssessment
WinSATAssessmentState : 3
WinSPRLevel           : 0
PSComputerName        : COMPNAME
是否有任何标志或特殊方法可以从x86进程访问此信息

谢谢。

你的问题是正确的

默认情况下,当存在两个版本的提供程序时,应用程序或脚本从相应的提供程序接收数据。32位提供程序将数据返回到32位应用程序,包括所有脚本,64位提供程序将数据返回到64位编译的应用程序。但是,应用程序或脚本可以通过方法调用上的标志通知WMI,从非默认提供程序(如果存在)请求数据。\uuuu ProviderArchitecture\uuuu RequiredArchitecture字符串标志具有一组由WMI处理但未在SDK头或类型库文件中定义的值。这些值被放置在上下文参数中,以向WMI发出信号,表明它应该从非默认提供程序请求数据

我不知道如何使用PowerShell cmdlet做到这一点,但您可以使用.NET Framework中的“System.Management”类(COM对象封装)

我在Windows8中以32位和64位PowerShell的位执行此脚本,这两种脚本都可以运行

# Setup the context information
$mContext = New-Object System.Management.ManagementNamedValueCollection
$mContext.Add( "__ProviderArchitecture", 64)
$mContext.Add( "__RequiredArchitecture", $true)

# Setup the Authrntification object
$ConOptions = New-Object System.Management.ConnectionOptions
#$ConOptions.Username = "computername\administrateur" # Should be used for remote access
#$ConOptions.Password = "toto"
$ConOptions.EnablePrivileges = $true
$ConOptions.Impersonation = "Impersonate"
$ConOptions.Authentication = "Default"
$ConOptions.Context = $mContext

# Setup the management scope (change with the computer name for remote access)
$mScope = New-Object System.Management.ManagementScope("\\localhost\root\cimV2", $ConOptions)

$mScope.Connect()

# Query
$queryString = "SELECT * From Win32_WinSAT"
$oQuery = New-Object System.Management.ObjectQuery ($queryString)
$oSearcher = New-Object System.Management.ManagementObjectSearcher ($mScope, $oQuery)
$oSearcher.Get();