【发布时间】:2020-11-10 05:29:57
【问题描述】:
下面我正在尝试创建嵌套数组并向其中添加数组元素,如下所示
$nArr = @(@('1','3'), @('5','7','9'), @('2','4','6'))
这是获取上述结构的脚本
$integ = @(2,3,3)
$nArr = ,@()
$nArr1 = @()
foreach ($pd in $integ) {
for($i=0;$i -lt $pd;$i = $i+1) {
$uinput= Read-Host -Prompt "Assign the pod numbers for"
Write-Output `n
$nArr1 += [array]$uinput
}
$nArr += @($nArr1)
}
我为$uinput 提供的输入是1,3,5,7,9,2,4,6
但是我通过上面的脚本得到的最终结构是
$nArr = @('1','3','5','7','9','2','4','6')
请提出建议!
【问题讨论】:
-
这能回答你的问题吗? Powershell Multidimensional Arrays
-
具体哪一部分澄清了我的疑惑
标签: powershell powershell-2.0 powershell-3.0 powershell-4.0 powercli