I am trying to use new WMI-class in Windows 8 MSFT_NetAdapter
instead of Win32_NetworkAdapter
using System;
using System.Management;
namespace TestAdapters
{
class Program
{
static void Main(string[] args)
{
string query = "SELECT * From MSFT_NetAdapter";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection adaptersCollection = searcher.Get();
foreach (ManagementObject adapterWmiObject in adaptersCollection) //System.Management.ManagementException
{
//...
}
Console.WriteLine("end.");
Console.ReadKey();
}
}
}
And I get an System.Management.ManagementException
on the the foreach
statement with message: Invalid class
I don't know, what does it mean. I compiled and ran code under Windows 8.1 x64, so this class must work.
How to use MSFT_NetAdapter
?
This class is not in the root\Cimv2
namespace.
Look for it in the root\StandardCimv2
namespace.
Look at the following Powershell:
PS C:\Scripts> Get-WmiObject MSFT_NetAdapter
Get-WmiObject : Invalid class "MSFT_NetAdapter"
At line:1 char:1
+ Get-WmiObject MSFT_NetAdapter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
PS C:\Scripts> Get-WmiObject MSFT_NetAdapter -Namespace root\StandardCimv2
SUCCESS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With