Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Exploring WMI: Integrate WMI into the .NET Framework

Once you learn how to integrate Windows Management Instrumentation (WMI) with the .NET Framework, you can utilize a completely new approach for managing system resources.


advertisement
Windows Management Instrumentation (WMI) is one of the most fascinating technologies for managing distributed corporate computer systems. As the Windows implementation for WBEM (Web Based Enterprise Management), a standard developed by the DMTF (Distributed Management Task Force), WMI allows a completely new approach for managing system resources on the Windows operating system—including not only PCs and servers, but also many network devices such as switches and routers.

You can now access BIOS data, memory, software components, and network devices through one simple, unified object model, referred to as the Common Information Model (CIM). One of the most common uses for WMI is the creation of VBScript or JScript scripts in the Windows Scripting Host environment to automate repetitive administrative tasks.

This article discusses the WMI and its integration with the .NET Framework Namespace System.Management.



System Requirements
To get the most benefit from this article, you need a good understanding of C# and object-oriented programming. A good knowledge of the Windows environment, including Services, Event Logs, and Active Directory, will be very helpful too. Although a deep understanding of the system internals isn't necessary, understanding its basics will be advantageous.

WMI is available for WinME, Windows 2000, or newer operating systems. The WMI SDK includes a WMI Provider for Windows NT 4.0 SP 3. Versions for Windows 9x are also available, although with some limitations.

The examples in this article should be used with the final release of Visual Studio.NET (2002) on Windows 2000 or XP machines. For older versions of the Windows operating system, use the WMI Providers in the WMI SDK, which you'll find in the download section of http://msdn.microsoft.com.

What Is WBEM and What's It Got to Do with WMI?
When you start using WMI you will come across the acronym WBEM and likely ask yourself: What's this all about? It stands for Web Based Enterprise Management, the technological standard behind WMI. Still unclear? Let me explain the ideas behind WBEM.

In the past few years, the management of large computer systems has grown more and more complex, establishing the need for a new, easy-to-adapt/implement management technology. Since Active Directory focuses on the management of user accounts and groups in an organization, a component that aggregates information about hardware was still missing. Typically, you find many different types of hardware in one organization: routers, switches, media converters, data storage systems, desktops, servers, etc.—all from different vendors running different operation systems. Maybe you have already experienced the difficulty of trying to find all available information about your local workstation. Now imagine how complex it would be to find all attributes of a network that contains several hundred devices. You would have to use many different tools from various vendors to access the needed information. This way of collecting hardware data is very cost intensive and, of course, quite error prone.

The total cost of ownership for large corporate networks clearly needed to come down. A good starting point was a new protocol/object model that unified the ways IT professionals ask different computer systems about their vital hardware information. Enter WBEM (see Figure 1). In 1998, the DMTF took ownership of the independent WBEM project and combined it with their CIM (currently in its second version, CIMV2).

CIM is a relatively simple model for managing a computer system's objects. It contains management objects for software and hardware elements. You can use CIM to represent relations between objects (e.g., a group that contains several user accounts). CIM itself is an open standard that the DMTF developed and maintains, so you can enhance it with your own management classes. The important CIM attribute is that it standardizes the way system components are accessed when information is needed.

Figure 1: WBEM Architecture

As stated previously, WMI is the windows implementation of the WBEM standard. So WMI offers a management infrastructure that represents the objects in a Windows operation system environment in a CIM conform way. Since WMI is also based on COM (Component Object Model) technology, you can also use it from ActiveX-capable scripting environments such as Windows Scripting Host (WSH) or Active Server Pages. In fact, this integration into the WSH makes WMI the best invention since sliced bread. Administrators can use it to check the attributes of all hardware devices in a network and start appropriate script actions (e.g., restarting a system service on any machine where it has stopped, or adding registry keys to each machine without having to log on locally to every workstation in the corporation). For further information on this topic, take a look at the Related Resources section in the left column.

CIM uses the Managed Object Format (MOF) description language (which is derived from IDL, the Interface Description Language) to model the CIM schemas. The schema describes the components of a system and represents information about their relationships. The schema data contained in the .mof files are in a machine- and human-readable format. You can take a look at them in the Windows subdirectory %windir%\System32\WBEM\. Just open them with your favorite text editor if you need more in-depth information about an object.

How's CIM Fit In?
Now that you know how information about individual objects is stored, you can examine the repository that stores the information for all objects of a specific system: the CIM Object Manager. The CIM Object Manager defines a structure, the CIM Repository Schema, which describes the enterprise-wide layout and context of management class objects. It is also the connection point for the various technologies that can access WMI.

Figure 2: CIM Repository Architecture

As Figure 2 illustrates, you can access the data in the CIM Repository in many ways. One of the most common is to use the WMI ActiveX controls with scripting languages to easily create administration scripts for your enterprise. You can also use WMI from within ADO or ODBC providers. However, the most interesting way to connect to the CIM Repository definitely is the .NET Framework with the namespace System.Management.

As you may have noticed, Figure 2 also shows a block with providers. These are the connectors from the CIM Object Manager to the represented software or hardware. Many different providers are installed on standard Windows machines. Some of the typical providers are:

  • Win32 Provider
  • WDM Provider
  • Event Log Provider
  • Registry Provider
  • Performance Counter Provider
  • Active Directory Provider
  • Windows Installer Provider

Many other providers are available from third-party vendors. You can even write custom WMI providers for your application needs. You will need the WMI SDK to create any custom providers. You can download the SDK from the Microsoft website.

For more information visit the DMTF Web site or the Microsoft Web site.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date