Skip to content

C# Class Library to easily query Windows Management Instrumentation (WMI).

License

Notifications You must be signed in to change notification settings

vsharmanov/EasyWMI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyWMI

EasyWMI is a C# Class Library that interfaces with Windows Management Instrumentation (WMI). The intended purpose for this class library is to provide an easy method to query WMI via C#.

Supported Alias(es) can be found here:

Easy Syntax

WMIData.cs

The WMIData class is a wrapper for the WMIProcessor class; it gives you a managed use of the WMIProcessor object.

// WMIData object with default request + Extra Request.
WMIData wmiData = new WMIData(true);
wmiData.GetData(WMI_ALIAS.NETWORK_INTERFACE_CARD_CONFIG, "ipaddress");

foreach ( var currentAlias in wmiData.Properties )
{
    Console.WriteLine(currentAlias.Key.Value);
    foreach( var currentProperty in wmiData.Properties[currentAlias.Key] )
    {
        Console.WriteLine("{0} : {1}", currentProperty.Key, currentProperty.Value);
    }
    Console.WriteLine();
}

WMIProcessor.cs

The WMIProcessor class uses a Process object to execute the request.

// Request WMI data from a remote machine.
WMIProcessor wmi = new WMIProcessor();
wmi.Request = WMI_ALIAS.CPU;
wmi.Filter = "name,threadcount,architecture";
wmi.RemoteExecute = true;
wmi.NodeName = "10.1.2.8";
String result = wmi.ExecuteRequest();

// Change RemoteExecute to false. Executes query on local machine.
wmi.RemoteExecute = false;
String result = wmi.ExecuteRequest();

// Shorthand Remote 
WMIProcessor wmi = new WMIProcessor("10.1.2.8", WMI_ALIAS.CPU, "name,threadcount,architecture", true);
String result = wmi.ExecuteRequest();

// Shorthand Local
WMIProcessor wmi = new WMIProcessor(WMI_ALIAS.CPU, "name,threadcount,architecture");
String result = wmi.ExecuteRequest();

Filter is optional for all cases.

About

C# Class Library to easily query Windows Management Instrumentation (WMI).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%