How do I convert from a Value code to a Valuemap string in a WMI MOF in Powershell?

Posted on 2009-02-20
Last Modified: 2012-05-06
After some marathon googling I'm still stuck on a simple task.  I can write a WMI query to retrieve a WMI class (in this case from HP's provided WBEM classes for ProLiant servers).  In this case, I am trying to get the NIC Team type.  The object returned contains the code.  Looking into the associated MOF file, I can see that the values correspond to a ValueMap, but I can't figure out how to convert the integer I have with the string in the MOF.  I have a feeling it's right under my nose, so could someone please show me?
$server = "SERVER1"

$wmiQuery = "SELECT * from HP_EthernetTeam"	

$nicTeam = Get-WmiObject -Namespace "root\HPQ" -ComputerName $server -query "$wmiQuery"

Write-Host Current mode $nicTeam.TeamCurrentOperatingMode


Current mode 1011

Open in new window

Question by:trader37
    LVL 18

    Expert Comment

    The easiest thing to do is to use a switch statement

    switch -exact ($value)
       "1101"    {"String Value"}
       "1001"    {"Another Value"}
       default    {"Unknow value: $_"}


    Author Comment

    Well that's obviously going to allow me to reach the end goal for this script, it doesn't help on subsequent ones.  Basically, I don't want to have to go into the .mof file for every WMI/WBEM script I'm going to write to look at the values, and then hard code them into my script.

    I want to be able to take values and reference them against their associated valuemap inside the .mof file to figure out what the strings should be.  This may be more a "how do I use a WBEM feature?" question than "how do I use a powershell feature?".
    LVL 18

    Accepted Solution

    There is no Powershell, or any other for that matter, feature that does what you want.

    I suppose you could write a mof parsing script and generate the info, but I do not imagine that is very simple.

    Author Closing Comment

    Which begs the question why have valuemaps anyway? >.<

    I did see one document mention that you *could* do it, but it didn't explain how.  However, it may be that the solution they were thinking of was parsing the file.

    Since it's the closest I'll get, the points are yours.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    Synchronize a new Active Directory domain with an existing Office 365 tenant
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now