Printer Friendly Version      Send     
Click to Rate and Give Feedback
Related Articles
Despite its object oriented nature, Windows PowerShell is also able to parse complicated strings. Don Jones demonstrates how you can do this in Windows PowerShell using Select-String.

By Don Jones (September 2008)
Discover how you can use disconnected recordsets—virtual database tables—to work around VBScript limitations relating to data-sorting and working with large data sets.

By The Microsoft Scripting Guys (September 2008)
With Windows Vista, the UserAccounts.CommonDialog ActiveX control for opening a file open dialog box no longer exists. Here's a look at how you can solve that problem using Visual Basic Express Edition.

By The Microsoft Scripting Guys (August 2008)
Don Jones discusses filtering functions, the pipeline, custom objects, and how ping-pong balls hold the secret to understanding Windows PowerShell.

By Don Jones (July 2008)
More ...
Popular Articles
Secure Multi-Purpose Internet Mail Extensions let you hide information in transit, validate senders, and authenticate messages. Learn how to secure e-mail using digital certificates and how to troubleshoot problems you may encounter on your S/MIME system.

By Matt Clapham and Blake Hutchinson (June 2008)
While locking is essential to support concurrent read and write activities on a database, blocking can adversely affect system performance. Learn how to optimize your SQL Server database to minimize blocking, and see how you can monitor the system to better understand how locking impacts performance.

By Cherié Warren (April 2008)
Michael Murgolo is back with an update to his Elevation PowerToys. You'll find enhanced Run as Administrator functionality that works with third-party scripting tools, a way to replace a handy Windows XP feature removed from Windows Vista, and many more useful tools.

By Michael Murgolo (June 2008)
Windows Server 2008 and the new Windows Server Backup utility bring many changes and welcome enhancements to backing up. Here is an in-depth guide to backing up and restoring Active Directory in the new server OS.

By Gil Kirkpatrick (May 2008)
More ...
Read the Blog
David Tesar recently posted an interview with Mark Russinovich. In the interview, Mark discusses joining ...
Read more!
In his third installment on Windows Deployment Services, Wes Miller explores features that enhance performance and scalability, logging, and command-line automation. Notable in this column are the powerful new command-line utility for management, WDSUtil.exe, and the WDS Image ...
Read more!
In the September 2008 issue of TechNet Magazine,  Raymond Chen reflects on how some left over diagnostic code unexpectedly Read more!
As the Scripting Guy notes, the old phrase "you can run but you can't hide" was never more true than it is today— when even your toaster can be Internet-enabled. But disconnection happens, and then what do you do? We—or rather the scripting guys—are ...
Read more!
Pav Cherny discusses the limitations of the built-in Directory Management Service in SharePoint and explains how you can replace this component with a custom solution that lets you synchronize SharePoint recipient information with other directory solutions. In particular, he ...
Read more!
"One of the common things that administrators must deal with on an ever-increasing basis is the regular changing of the password for shared and privileged accounts, such as the built-in administrator or root account, a firecall account, or perhaps even a process account." In the Read more!
More ...
Utility Spotlight WMI Code Creator
Chris Scoville

Download the code for this article: WMI Code Creator (122KB)

As a systems administrator you’re surely no stranger to Windows®Management Instrumentation (WMI), which gives you access to a wealth of management information and allows you to automate administrative tasks. To take full advantage of WMI you have to write queries to extract the information you need. And if you don’t have the ready-made queries already floating around in your head, you just might want to take the WMI Code Creator for a spin. It’s a recently released tool that generates custom code to use WMI so you can get the most from the myriad of computer management options that WMI has to offer.
The WMI Code Creator can generate code in VBScript, C#, and Visual Basic® .NET; you can run the code directly from the tool. You can generate code to query for management information, execute a management task, or receive event notifications.
For example, suppose you want to get a list of all the services running on a computer. You can use the WMI Code Creator to query for this information by selecting the WMI class you want to query (Win32_Service) and the properties that contain the information you are interested in accessing. And you can do more than just execute queries. Let’s say you want to start a service that isn’t running. You can use the WMI Code Creator to generate a script to do that too. All the code is generated for you based on a few selections you make. Plus, the tool contains step-by-step help to teach you how to use it to get the information you want.
The WMI Code Creator generates code that you can point at remote computers as well. You can query for the same kind of data you can get on local computers, receive event notifications, and even execute tasks remotely. All you need to do is enter the domain and name of the remote computer, and the code is generated automatically.
Figure 1 shows an example of event notification code generated by the WMI Code Creator. Note that you can set the frequency at which WMI should poll for the specified events, and you can edit or execute the code as well.
Figure 1 WMI Code Creator Generating Event Notification Code 
If you aren’t familiar with all of the WMI classes and their uses, the WMI Code Creator lets you browse through the available WMI classes on your computer, and displays descriptions of these classes, their properties, and methods. The WMI Code Creator also lets you quickly access the documentation for a WMI class by linking you to the specific class page in the MSDN® WMI documentation online.
The WMI Code Creator download also includes the source code, which serves as a really handy tool for learning how to use the System.Management classes in the Microsoft® .NET Framework to access WMI. The tool was built using WMI, and the source code provides many examples for how to use WMI to add functionality to an application.
Use the tool to open up a world of WMI functionality and all the computer management possibilities it provides. It will save you time writing administrative scripts and code, and provide you with excellent examples and solutions. You can download the utility from WMI Code Creator.

Chris Scoville is a programming writer in the Windows Server Developer Documentation group at Microsoft. He writes documentation and code examples for management technologies. He developed the WMI Code Creator tool.  Chris can be reached at chscovil@microsoft.com
© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker