Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2009-02-20
4
Medium Priority
?
1,058 Views
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
 
Output:
Current mode 1011

Open in new window

0
Comment
Question by:trader37
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:BSonPosh
ID: 23700021
The easiest thing to do is to use a switch statement

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

}
0
 

Author Comment

by:trader37
ID: 23713276
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?".
0
 
LVL 18

Accepted Solution

by:
BSonPosh earned 150 total points
ID: 23713310
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.
0
 

Author Closing Comment

by:trader37
ID: 31549434
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.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

564 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