Export (0) Print
Expand All

Creating Scripts Based on WMI Templates

Microsoft® Windows® 2000 Scripting Guide

WMI has a reputation for being very difficult to learn and even more difficult to use. In many respects, this reputation has been acquired not so much because WMI really is difficult but simply because it is so big. WMI can be used to manage computer hardware, computer software, and nearly everything in between; the assumption is that any technology that encompasses so many different elements must be difficult.

In reality, though, many of the system administration tasks that can be performed by using WMI follow one of a handful of standard approaches. For example, you have already seen how a template can serve as the basis for scripts that return information about almost any managed resource. In the opening pages of this chapter, the same basic script with one or two minor modifications was used to return information about items as disparate as installed memory, services, and events recorded in the event logs.

The following sections of this chapter present basic script templates that can be used to:

  • Retrieve and display the properties of a managed resource.

  • Configure the property values of a managed resource.

  • Call the methods of a WMI class.

  • Create new instances of managed resources.

  • Delete existing instances of managed resources.

Note

  • All of the script templates are designed to work on the local computer; this is done by setting the value of the variable strComputer to a dot ("."). To run a script against a remote computer, simply set the value of strComputer to the name of the remote computer. For example, this line of code causes a script to run against a computer named atl-dc-01:

  • 
    strComputer = "atl-dc-01"
    
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft