Writing WMI Scripts

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

One point that has been reiterated throughout this chapter is that most WMI scripts follow a simple three-step pattern. In general, WMI scripts:

  1. Connect to the WMI service.
  2. Retrieve a WMI object or collection of objects.
  3. Perform some sort of task on the object or objects. Until now, this task has largely been confined to reporting property values. However, you can also do such things as run methods, configure property values, and create or delete instances.

To become proficient in writing WMI scripts, you need to understand the nuances of these three steps. The preceding section of this chapter was a bit more theoretical in nature: It provided useful background information for understanding what WMI is and what it can do. This portion of the chapter takes a more practical approach; in particular, it provides a detailed look at the three steps used in most WMI scripts. This is done by:

  • Explaining the use of the WMI moniker, a versatile method for connecting to the WMI service.
  • Explaining the use of ExecQuery, an SWbemServices method that provides an alternative (and typically better and faster) way to retrieve WMI data.
  • Providing a series of templates that can serve as the basis for scripts that carry out common tasks such as retrieving information, configuring property values, executing methods, and creating or deleting instances.

In addition to detailing the three steps in a typical WMI script, this section also looks at two other important elements in script writing: working with WMI dates and times, and monitoring events.


send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net