WMI GetMultiStringValue question

Ask your 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.
This topic is 11 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
EBrant
Posts: 99
Last visit: Wed Apr 23, 2014 2:22 am

WMI GetMultiStringValue question

Post by EBrant »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

WMI GetMultiStringValue question

Post by jvierra »

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
Last visit: Wed Apr 23, 2014 2:22 am

WMI GetMultiStringValue question

Post by EBrant »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

WMI GetMultiStringValue question

Post by jvierra »

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)
This topic is 11 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked