Mr. Roboto

Your First Fishing Lesson

In anticipation of PowerShell 2.0, Mr. Roboto gives a few pointers on how to get the most out of it -- starting with Windows Management Instrumentation.

I know it's cliché, but I'm a big fan of teaching others "how to fish" so they can take care of themselves. Mr. Roboto will often offer suggestions and tools to help you get the job done in an efficient and cost-effective manner, but I also want you to know more about how things work so you can develop your own solutions. Because more and more of you will begin using Windows PowerShell -- especially with the arrival of version 2.0 in a few months -- I'll use it as the basis for my scripted solutions.

I can't teach you everything about using Windows PowerShell in a monthly column; in any case, I'm a proponent of learning by doing. The more you understand how something works, the more you see how easy it is. So, on with the fishing lesson.

Make Use of WMI
In Windows PowerShell, Windows Management Instrumentation (WMI) is an amazing way to gather all sorts of information about remote computers. Using the Get-WMIObject cmdlet and a WMI class name, you'll be amazed what you can discover:

PS C:\> get-wmiobject -class 
win32_bios -computername 

The challenge is discovering which classes to use. In PowerShell, all you need to do is ask. The Get-WMIObject cmdlet has a -list parameter. The default WMI namespace is Root\CIMv2, which is perfect because 90 percent of your WMI scripting will use the Win32 classes in this namespace. Here's a simple PowerShell expression to display just the Win32 classes on your computer:

PS C:\> Get-wmiobject -list | 
where {$ -like "Win32*"} 

Most of the class names should be self-explanatory, but what type of objects will they create? There are a number of free WMI scripts and browsers you can download and use, but I have a short script you can download from (see "Roboto on Demand").

Get-WMIInfo.ps1 is designed to display the help description for a given class, along with the class' properties and methods. The script will write a custom object with WMI information to the pipeline, or you can use -report to display an expanded view of the class' properties and methods. The script can also connect to a remote computer. Be aware that the script can't use alternate credentials to connect to remote computers: You must run it under an account that has administrator privileges on the remote computer.

PS C:\Scripts\.\get-wmiinfo.ps1 
-computername FILE01 -class 

This script is designed to give you information about a WMI class so you can later write your own PowerShell scripts and expressions. The script can accept several parameters.


I've given most of the parameters' default values. You can either specify values in the same order as the parameter variables, or you can treat the variables as runtime parameters as I did in my example.

The script creates a WMIClass object constructed from the computername, namespace and class:

{1}:{2}" -f $computername, 

The -f operator replaces the numbered placeholders with the corresponding value from the comma-separated list on the right. This is a very handy technique for building strings because there's no more complicated concatenation.

I hope you find Get-WMIInfo.ps1 a helpful tool for discovering WMI information. There's a lot more about this topic online at, including advice for creating property and method names for WMI classes.

Roboto on Demand

To download Mr. Roboto's Get-WMIInfo.ps1 script and learn about creating and displaying properties and methods, click here.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at, and a frequent speaker at technology conferences and user groups.


  • Microsoft Intune Gets Role-Based Access Control

  • Microsoft Intune Can Now Deploy Office 365 ProPlus Apps

  • Microsoft To Block EMET in Windows 10 Fall Creators Update

comments powered by Disqus

Office 365 Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.