Adotou a solução JPBlanc de esta resposta no StackOverflow
# 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_PerfFormattedData_NETFramework_NETCLRMemory"
$oQuery = New-Object System.Management.ObjectQuery ($queryString)
$oSearcher = New-Object System.Management.ManagementObjectSearcher ($mScope, $oQuery)
$oResult = $oSearcher.Get();
$oResult.Name # only for simple check that current code snippet gives
# the same results from both 32 and 64 -bit version of PowerShell
Requesting WMI Data on a 64-bit Platform
By default, an application or script receives data from the corresponding provider when two versions of providers exist. The 32-bit provider returns data to a 32-bit application, including all scripts, and the 64-bit provider returns data to the 64-bit compiled applications. However, an application or script can request data from the nondefault provider, if it exists, by notifying WMI through flags on method calls.
Context Flags The
__ProviderArchitecture
and__RequiredArchitecture
string flags have a set of values handled by WMI but not defined in SDK header or type library files. The values are placed in a context parameter to signal WMI that it should request data from the nondefault provider.
The following lists the flags and their possible values.
__ProviderArchitecture
Integer value, either 32 or 64, that specifies the 32-bit or 64-bit version.__RequiredArchitecture
Boolean value used in addition to__ProviderArchitecture
to force load the specified provider version. If the version is unavailable, then WMI returns the error0x80041013
,wbemErrProviderLoadFailure
for Visual Basic andWBEM_E_PROVIDER_LOAD_FAILURE
for C++. The default value for this flag when it is not specified isFALSE
.On a 64-bit system that has side-by-side versions of a provider, a 32-bit application or script automatically receives data from the 32-bit provider, unless these flags are supplied and indicate that the 64-bit provider data should be returned.