【发布时间】:2013-08-12 15:17:02
【问题描述】:
我正在尝试将数组转换为哈希表,但我不断收到此错误
无法索引到 System.Management.Automation.PSObject 类型的对象。
我到处搜索,找不到其他有同样问题的人。
我的代码:
[array]$compArray = $ds3 | select -Property DeviceName, IP_Address
$DeviceHashtable = @{}
$compArray[0][0]
for ($i=0;$i -lt $compArray.length;$i++)
{
$1=[string]$compArray[0][$i];
$2=[string]$compArray[1][$i];
$DeviceHashTable.add("$1", "$2")
}
$ds3 是一个 system.data.datatable 对象 如果我做 $compArray | display-table 我想要的所有数据都在那里。 任何帮助表示赞赏:)
【问题讨论】:
标签: arrays powershell hashtable