WMIHelper ClassCleanCode C# Libraries v1.2.03 API
Streamlines access to the OnlineWMI.
Inheritance Hierarchy

OnlineSystem Object
  CleanCode.Net WMIHelper

Namespace: CleanCode.Net
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public class WMIHelper
Remarks

WMI (Windows Management Instrumentation) allows querying remote computers for key data. The full WMI allows control of remote computers as well. WMIHelper provides some support methods to streamline access. For a list of sections and keys, see the OnlineWMI reference. Also, OnlineWMI Explorer is useful for actually exploring values returned by WMI.

Since CleanCode 0.9.07.

Examples

The first step is to create an instance using one of the constructors. You may specify a remote host with or without a section:
wmiHelper = new WMIHelper(server, domain, user, pwd);
wmiHelper = new WMIHelper(server, domain, user, pwd, section);
wmiHelper = new WMIHelper();
wmiHelper = new WMIHelper(section);
or a local host likewise: Next invoke the Connect  method to connect the scope.
wmiHelper.Connect();
And now you are ready to execute queries. If you pre-selected a section in the constructor, you only need the single-argument GetInfo(String). If you did not, or you want to change the section, then you use the SetSection(String) method or the dual-argument GetInfo(String, String).
wmiHelper.SetSection("Win32_OperatingSystem");
string serverOSName = wmiHelper.GetInfo("Caption");
string serverIPLabel = wmiHelper.GetInfo(
    "Win32_NetworkAdapterConfiguration", "IPAddress");
See Also