I have an hashtable with a below structure,
$podhashtable = @{2 = '1','2' ; 3 = '3','4','5' ; 1 = '6'}
Here is the code how I achieve the above hashtable,
$podnumbers = @(2,3,1)
$podInfo = @()
$podhashtable = [ordered]@{}
$buff = 0
foreach ($pd in $podnumbers) {
#$podInfo = @()
for($i=0;$i -lt $pd;$i = $i+1) {
$pod = Read-Host -Prompt "Assign the pod numbers for",$esxarray[$buff]
$podinfo += $pod
}
$podInfoOb = New-Object PSObject –Property $podsets
$podsets = @{$pd = $podInfo}
$podhashtable += $podsets
$buff = $buff + 1
}
Write-Output $podhashtable
I'm trying to create array of hashtable like below,
$podhashtable = @{2 = '1','2'}, @{3 = '3','4','5'}, @{1 = '6'}
What is the best way to get the above array of hashtable?