Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 15, 2004

Take Advantage of Scriptomatic 2.0 to Maximize Your WMI Scripting Efforts

It’s not just for novice scripters
RSS
Subscribe to Windows IT Pro | See More Task Automation Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

Scriptomatic 2.0 will soon be released. Many of you are probably saying, "It's about time!" Scriptomatic 2.0 certainly improves on its predecessor, and I cover many of those improvements in Rem "Scriptomatic 2.0 Is Worth the Wait." The purpose of this article is to help you get the most out of Scriptomatic 2.0. Microsoft's Scripting Guys intended that this tool be used to help novice Windows Management Instrumentation (WMI) scripters see the consistency inherent in WMI scripts that read WMI class properties. The tool accomplishes this task quite well. However, it also serves as an excellent launching point to building more sophisticated scripts. In this article, I explain what you can infer from the information Scriptomatic provides, point you to important tools that expand on the information provided by Scriptomatic, and demonstrate how you can augment the Scriptomatic code so that it provides even more class information.

What's on the Surface
The simplest and most obvious use for Scriptomatic is reading and displaying a class's properties and their values. When Scriptomatic 2.0 loads, it defaults to the root\CIMV2 namespace, then loads the classes in that namespace. You select a WMI class, such as Win32_ComputerSystem, to generate a script.

After Scriptomatic 2.0 generates the code, you can immediately run the script or save it to a file so that you can use it to create more complex code. If you run the script, you can output the results as command output in the command-shell window, as a text file for viewing in Notepad or another editor, as an HTML or XML file for viewing in a browser such as Microsoft Internet Explorer (IE), or as a comma-separated value (CSV) file for viewing in Microsoft Excel or another spreadsheet program.

If you want to build more complex code from the script, you need to have some proficiency in a scripting language such as VBScript or Perl. Scriptomatic 2.0 provides you with simple scripts in VBScript, JScript, Perl, and Python. From there, you can use your language of choice to build production-level code.

Scriptomatic 2.0 alone won't give you a complete picture, which is why you need several WMI-specific tools and references in your toolkit. Here's a list of essential WMI tools and documentation that you can use to expand on the information Scriptomatic 2.0 provides:

  • WBEMTest. WBEMTest is part of every OS installed with WMI. It's not the easiest tool to master, but it has the advantage of always being there.
  • WMI CIM Studio. WMI CIM Studio is a powerful and intuitive Web-based interface for digging into WMI. It's part of the WMI Administrative Tools suite. Those who don't already have this suite of tools can download it from http://www.microsoft.com/downloads/details.aspx?displaylang=en&familyid=6430f853-1120-48db-8cc5-f2abdc3ed314.
  • WMI software development kit (SDK) documentation. The WMI SDK documentation is available online at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_start_page.asp. If you don't have an always-on Internet connection, you might prefer to download the Windows Server 2003 Core SDK from http://www.microsoft.com/msdownload/platformsdk/sdkupdate. The WMI SDK documentation is part of the Core SDK.
  • "WMI Scripting Primer." I often reference the three-part article "WMI Scripting Primer" because, in relatively few pages, it provides powerful insights into the WMI architecture and the WMI scripting API. If you haven't already read this primer, I urge you to do so. "WMI Scripting Primer: Part 1" is at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting06112002.asp. You can access the other parts from the directory on the right side of this Web page.

A Path to WMI Scripting
Scriptomatic 2.0 is a great starting point for developing powerful WMI scripts. It lets you quickly evaluate a bunch of classes and their properties in a namespace. You can determine the namespaces available in an OS. You can list properties of a class, or lack thereof. A lack of properties might suggest that the class is rich in methods. With a little support from other tools or scripts, you can find properties that you can write or change, determine the data types of available properties, and learn more about class methods.

Using Contrast as an Effective Learning Tool
Scriptomatic 2.0 lets you select other WMI namespaces besides the common root\CIMV2 namespace. CIMV2 is the only namespace available in version 1.0. In version 2.0, you can gain insight on whether a namespace (i.e., provider) is available on other platforms. For example, the root\MicrosoftIISv2 provider is available on Windows 2003 computers running Microsoft IIS 6.0. In contrast, this namespace isn't available on computers running Windows XP and IIS 5.1 because the MicrosoftIISv2 provider is available only on IIS 6.0.

To see this contrast, launch Scriptomatic 2.0 on a computer running Windows 2003 and IIS 6.0 and browse the listed WMI namespaces in the WMI Namespace drop-down list box. Then, launch Scriptomatic 2.0 on a computer running XP and IIS 5.1 and again browse the listed namespaces. You'll see that the MicrosoftIISv2 provider is available in Windows 2003 but not XP. Thus, if you're building a script to modify the IIS metabase, you'll know that IIS 6.0 has a powerful WMI provider available for that purpose. (For more information about this provider, see Rem "Using WMI to Change HTTP Compression Settings.")

You can use the contrast technique for more than WMI namespaces. After you select a namespace, you can see class differences from one OS to the next. For example, if you select the root\DEFAULT namespace on an XP or Windows Me computer with the System Restore feature enabled, you'll see the System Restore class in the WMI Class drop-down list box. In contrast, because System Restore isn't an available feature in Windows 2003, you won't see this class in the root\DEFAULT namespace. Thus, if you're building a script to configure or retrieve System Restore checkpoints, you now know that this class is available on a small subset of client OSs.

   Previous  [1]  2  3  Next 


Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Task Automation Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Will Your Next Generation Server System Meet Your Infrastructure Optimization Needs?

Continuous Data Protection and Recovery for Microsoft Exchange

Related Events Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement