Get-CSRegistryValue problem when returning only one result
jdness opened this issue · 1 comments
I think there is some data type confusion when Get-CSRegistryValue returns just one result. In this new 0.6.1 code you fixed to maintain PSv3 compatibility (thank you!), you build an array of types:
$Types = foreach ($Value in $Result.Types) { $Type[$Value] }
When more than one result is returned, this works fine and $Types is an Object[]. However, when only one result is returned, $Types ends up being a String. And then when you later index into $Types with $Types[$i] it returns one of the characters of that string.
In my testing, either of the following fixes worked fine:
[String[]]$Types = foreach ($Value in $Result.Types) { $Type[$Value] }
or
$Types = @()
foreach ($Value in $Result.Types) {
$Types += $Type[$Value]
}
Thanks!
Thanks a lot for the report and fix suggestion! I like your idea for explicitly casting as a byte array. You want to test in the dev branch and get back to me? Works for me in my testing. I'll merge to master after you test.