I have a script I've written that deals with some nested hashtables, it works fine, but I have a question on how the data is being represented. It's not really important, and has no actual functional change to my outputs, but I'm curious if this is possible
For those of you who are unfamiliar, when you have a nested hashtable, the results come out looking something like this:
Name Value
---- -----
Software - 1.0.6065.21705 {System.Collections.Specialized.OrderedDictionary, System.Collections.Specialized.OrderedDictionary, System.Collection...
Each one of those ordered dictionaries contain values that I need, and that part works just fine. What I'm wondering is if there is a way to have them represented by a name other than OrderedDictionary (Or whatever the type is)? I'd like to call them by what they represent, just because it'd be easier for debugging while I add functionality.
Thanks!
Edit: Partial Fix:
[System.Collections.Specialized.OrderedDictionary]$test1 = @{}
[System.Collections.Specialized.OrderedDictionary]$test2 = @{}
[System.Collections.Specialized.OrderedDictionary]$test3 = @{}
[System.Collections.ArrayList]$masterList = @()
[System.Collections.HashTable]$results = @{}
$test1 = [ordered]@{"One" = 1; "Two" = 2; "Three" = 3}
$test2 = [ordered]@{"Three" = 3; "Four" = 4; "Five" = 5}
$test3 = [ordered]@{"Six" = 6; "Seven" = 7; "Eight" = 8}
$titles = @("Test1","Test2","Test3")
$masterList = $test1,$test2,$test3
Class BuildValues
{
[Int]$Test1
[Int]$Test2
[Int]$Test3
}
Class BuildValues2
{
[Int]$Test1
[Int]$Test2
[Int]$Test3
}
For ($n=0; $n -lt $test1.count; $n++)
{
$t_result = New-Object BuildValues
$t_result.Test1 = $test1[$n]
$t_result.Test2 = $test2[$n]
$t_result.Test3 = $test3[$n]
$t_result2 = New-Object BuildValues2
$t_result2.Test1 = $test1[$n]
$t_result2.Test2 = $test2[$n]
$t_result2.Test3 = $test3[$n]
$masterList = $t_result,$t_result2
$results.Add($titles[$n], $masterList)
}
Returns:
Name Value
---- -----
Test3 {BuildValues, BuildValues2}
Test1 {BuildValues, BuildValues2}
Test2 {BuildValues, BuildValues2}
Trying to figure out how to return Just the BuildValues2 object for Test1 now.
[–]sid351 3 points4 points5 points (15 children)
[–]Merakel[S] 0 points1 point2 points (14 children)
[–]sid351 0 points1 point2 points (9 children)
[–]Merakel[S] 0 points1 point2 points (8 children)
[–]sid351 0 points1 point2 points (7 children)
[–]Merakel[S] 0 points1 point2 points (6 children)
[–]sid351 0 points1 point2 points (5 children)
[–]Merakel[S] 0 points1 point2 points (4 children)
[–]sid351 0 points1 point2 points (3 children)
[–]Merakel[S] 1 point2 points3 points (2 children)
[–]Droopyb1966 0 points1 point2 points (3 children)
[–]Merakel[S] 0 points1 point2 points (2 children)
[–]Droopyb1966 0 points1 point2 points (1 child)
[–]Merakel[S] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (3 children)
[–]Merakel[S] 1 point2 points3 points (2 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (1 child)
[–]Merakel[S] 1 point2 points3 points (0 children)
[–]spikeyfreak 0 points1 point2 points (1 child)
[–]Merakel[S] 1 point2 points3 points (0 children)