1、附录 附录 原文: Windows Management Instrumentation Windows Management Instrumentation (WMI) (or Windows Management Interface) is a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification. WMI is Mi
2、crosofts implementation of the Web-Based Enterprise Management (WBEM) and Common Information Model (CIM) standards from the Distributed Management Task Force (DMTF). WMI allows scripting languages like VBScript or Windows PowerShell to manage Microsoft Windows personal computers and servers, both lo
3、cally and remotely. WMI is preinstalled in Windows 2000 and newer OSs. It is available as a download for Windows NT, Windows 95 and Windows 98. 1 Purpose of WMI The purpose of WMI is to define a non-proprietary set of environment-independent specifications which allow management information to be sh
4、ared between management applications. WMI prescribes enterprise management standards and related technologies that work with existing management standards, such as Desktop Management Interface (DMI) and SNMP. WMI complements these other standards by providing a uniform model. This model represents t
5、he managed environment through which management data from any source can be accessed in a common way. 2 Overview In order to unify the management techniques for the sake of simplicity, the DMTF defined CIM to represent real-world manageable entities in a unified way.The CIM object model is an object
6、 database model using terms and semantics that are unique to all constructors and software developers. This object model is implemented in a database called the CIM repository. Based on the CIM model, WMI includes real-world manageable components, available from the DMTF standards with some specific
7、 extensions that represent the various Windows components. Moreover, WMI exposes a collection of COM-scriptable objects that allow various applications to take advantage of the management information. As part of the installation process, most of the Microsoft applications available today (e.g. SQL S
8、erver, Exchange Server, Microsoft Office, Internet Explorer, Host Integration Server, Automated Deployment Services) extend the standard CIM object model to add the representation of their manageable entities in the CIM repository. This representation is called a WMI class, and it exposes informatio
9、n through properties and allows the execution of some actions via methods. The access to the manageable entities is made via a software component, called a provider which is simply a DLL implementing a COM object written in C/C+. Because a provider is designed to access some specific management info
10、rmation, the CIM repository is also logically divided into several areas called namespaces. Each namespace contains a set of providers with their related classes specific to a management area (i.e. RootDirectoryDAP for Active Directory, RootSNMP for SNMP information or RootMicrosoftIISv2 for Interne
11、t Information Services information). To locate the huge amount of management information available from the CIM repository, WMI comes with a SQL-like language called the WMI Query Language (WQL). 3 Development process Because WMI abstracts the manageable entities with CIM and a collection of provide
12、rs, the development of a provider implies several steps. The major steps can be summarized as follows: Step 1 Create the manageable entity model Define a model Implement the model Step 2 Create the WMI Provider Determines the provider type to implement Determines the hosting model of the provider Cr
13、eate the provider template with the ATL wizard Implement the code logic in the provider Register the provider with WMI and the system Step 3 Test the provider Step 4 Create consumer sample code 4 Importance of WMI providers Since the release of the first WMI implementation during the Windows NT 4.0
14、SP4 era (as an out-of-band download), Microsoft has consistently added WMI providers to Windows. Under Windows NT 4.0, Microsoft had roughly 15 WMI providers available once WMI was installed. When Windows 2000 was released, there were 29 WMI providers as part of the operating system installation. Wi
15、th the release of Windows Server 2003, Microsoft included in the platform more than 80 WMI providers. Windows Vista includes 13 new WMI providers,5 taking the number close to around 100 in all, and Windows Server 2008 includes some more including providers for IIS 7, PowerShell and virtualization. T
16、his has been a sign for many customers that WMI became at Microsoft, the ubiquitous management layer of Windows, even if this commitment has never been explicit from Microsoft. During these last years, due to a constant increasing exposure of management data through WMI in Windows, more and more peo
17、ple in the IT systems management field started to develop scripts and automation procedures based on WMI. Beyond the scripting needs, most leading management software in the world, such as MOM, SMS, ADS, HP OpenView for Windows (HPOV), BMC Software or CA, Inc. are WMI-enabled and capable to consume
18、and provide WMI information through various User Interfaces. This enables administrators and operators, not capable of scripting or programming on top of WMI, to enjoy the benefits of WMI without even learning about it. However, if they want to, because WMI is scriptable, it gives them the opportuni
19、ty to consume WMI information from scripts or from any Enterprise Management software that is WMI-aware. 5 Features For someone willing to develop one or many WMI providers, WMI offers many features out of the box. Here are the most important advantages: (1) Automation interfaces: Because WMI comes
20、with a set of automation interfaces ready to use, all management features supported by a WMI provider and its set of classes get the scripting support for free out-of-the box. Beyond the WMI class design and the provider development, the Microsoft development and test teams are not required to creat
21、e, validate and test a scripting model as it is already available from WMI. (2) .NET Management interfaces:Because the System.Management namespace 6 relies on the existing COM/DCOM plumbing, the created WMI provider and its set of WMI classes becomes automatically available to all .NET applications
22、independently of the language used (e.g. C#, VB.NET). Beyond the WMI class design and the provider development, like for scripting, the Microsoft development and test teams are not required to create, validate and test new assemblies to support a new namespace in the .NET Framework as this support is already available from WMI for free. (3) C/C+ COM/DCOM programming interfaces:Like most components in Windows, COM/DCOM programmers can leverage the features of the provider they develop at the COM/DCOM interfaces level. Like in previous environments