【发布时间】:2020-10-29 12:29:15
【问题描述】:
这是我使用哈希表数组的代码
$podnumbers = @(1,3,1)
$podInfo = $null
$buffer = 0
$podarray = foreach ($pd in $podnumbers) {
$podinfo = @()
for($i=0;$i -lt $pd;$i = $i+1) {
$pod = Read-Host -Prompt "Assign the pod numbers for",$esxarray[$buffer]
Write-Output `n
}
@{$pd = $pod}
$buffer = $buffer + 1
}
我给 $pod 的输入是 1 = 1 ; 3 = 2,4,6; 1 = 3
我希望我的哈希表数组如下所示,
Key : 1
Value : 1
Name : 1
Key : 3
Value : 2,4,6
Name : 3
Key : 1
Value : 3
Name : 1
但我得到的实际输出是,
Key : 1
Value : 1
Name : 1
Key : 3
Value : 2
Name : 3
Key : 3
Value : 4
Name : 3
Key : 3
Value : 6
Name : 3
Key : 1
Value : 3
Name : 1
【问题讨论】:
-
你不需要 - 要么添加/修改现有的 key'd 条目,要么找到字典类型以外的东西来保存你的数据:)
-
既然您似乎配置了 ESX Pod,也许edit 的问题并解释您正在尝试做什么。您可能需要反转键和值。
-
编辑了我的目标
标签: powershell powershell-5.0 powercli