WMI GetMultiStringValue question

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
EBrant
Posts: 99
Joined: Thu Feb 02, 2012 1:51 am

WMI GetMultiStringValue question

Post by EBrant » Thu Feb 28, 2013 12:52 am

Hello All

I have a registry key as follows

HKLMSYSTEMCurrentControlSetservicesTcpipParameters

which contains a Multi String value called

ReservedPorts

the value data for this Multi String value name is

1433-1434
1024-3343

i.e. two lines of text.

I am using the following code to output the above

$HKLM = 2147483650 #HKEY_LOCAL_MACHINE
$Server = "MyServer"
$reg = [wmiclass]"$Serverrootdefault:StdRegprov"
$key = "SYSTEMCurrentControlSetservicesTcpipParameters"
$value="ReservedPorts"
$ReservedPorts = $reg.GetMultiStringValue($HKLM,$key,$value)
$ReservedPorts.sValue

However it returns one of the two values i.e. the last value 1024-3343

Now I think I need to enumerate through a collection to get each value in turn? but cannot get the syntax right. Alternatively do I need to used another methods to get all the values of this multi string?

Thanks in advance
Ernie

User avatar
jvierra
Posts: 13798
Joined: Tue May 22, 2007 9:57 am
Contact:

WMI GetMultiStringValue question

Post by jvierra » Thu Feb 28, 2013 4:09 am

If you look more closely you will se it is returning both values as an array. When printed to the screen they will be displayed as a list.

User avatar
EBrant
Posts: 99
Joined: Thu Feb 02, 2012 1:51 am

WMI GetMultiStringValue question

Post by EBrant » Thu Feb 28, 2013 8:01 am

Thanks Jim, your right :)
tried it on my home PC works as expected, tried it on works PC did not work as expected. Must be some thing weird going on at work.

Thanks again Jim, I am off to Pombal in Portugal in 4 weeks thank good :)

Ernie

User avatar
jvierra
Posts: 13798
Joined: Tue May 22, 2007 9:57 am
Contact:

WMI GetMultiStringValue question

Post by jvierra » Thu Feb 28, 2013 8:38 am

Ernie
If you can program teh scanner fo tabs all is much easier.

Stop bragging about going off to have fun in the badlands of Portugal. We will save some of the remaining winter for you. You can't get away.I think my cousin is somewhere around there or maybe he is still in the Azores. (I think it is warmer in the Azores then in Pombal)

Locked