Richard's profileRichard Siddaway's BlogPhotosBlogLists Tools Help

Blog


    February 19

    Discovering WMI

    One thing that seems to come up rather frequently on the newsgroups is what WMI class do I need to use to do X.

    The really confusing thing about WMI is knowing just what is available. I have done far more with WMI since discovering PowerShell than I ever did with VBScript. That’s for 2 reasons. Firstly WMI is massively easier to use with PowerShell and it is easier to find out what you need to use.

    WMI is arranged in a hierarchy of namespaces.  Most of the useful stuff can be found in the default namespace ‘root\cimv2’  We can find out what is available quite easily by using

    001
    Get-WmiObject -List

     

    This will generate a long list of classes.  If you have an idea of what you want to look at then we can try something like

    001
    Get-WmiObject -List *printer*

     

    which will return all of the classes relating to printers.  WMI classes are named fairly sensibly so it is easy to vary the search if you don’t quite get what you need.

    Other good ways for discovering WMI – use PowerGUI – it has a WMI browser or download wmiexplorer from http://thepowershellguy.com/blogs/posh/archive/2007/03/22/powershell-wmi-explorer-part-1.aspx

    Which ever way you decide to follow to discover WMI – it will be a big part of your PowerShell tool kit.

     

    Technorati Tags: ,

    Comments (1)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    WMI classes exist in namespaces. Your examples will find the classes in the default namespace. if you want to look in ALL namespaces you would do this:

    PS> Get-WMIObject -NameSpace root -Recurse -List *Printer*

    Experiment! Enjoy! Engage!

    Jeffrey Snover [MSFT]
    Windows Management Partner Architect
    Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
    Feb. 20

    Trackbacks

    The trackback URL for this entry is:
    http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!2084.trak
    Weblogs that reference this entry
    • None