在 PowerShell 中实现 HashMap 时遇到问题。我已经使用 ReST 响应创建了 HasMap
$response_connection_hashmap = $response_connection|foreach {
@{ $_.name = $_.id }
}
我正在使用成功验证 hasmap
$response_connection_hashmap.GetEnumerator()|Sort-Object Name
但是,在按键搜索值时,我在下面使用
$response_connection_hashmap.Item("Key01")
低于错误
Exception getting "Item": "Cannot convert argument "index", with value:
"Key01", for "get_Item" to type "System.Int32": "Cannot convert value
"Key01" to type "System.Int32". Error: "Input string was not in a correct
format."""