在函数中使用 hash table 参数
Using hash table parameter in function
我正在尝试在我的脚本中构建哈希表。输入是一个参数:
Param
(
[hashtable]$param
)
调用我的函数:Foobar -Param 'Key, value'
不起作用。也试过:
Foobar -Param 'Key' = 'Value';
Foobar -Param Key Value
返回错误:Cannot convert value of type "System.String" to type "System.Collections.Hashtable".
如何正确传递参数?
使用哈希表文字 @{}
:
Foobar -Param @{ Key = 'Value' }
我正在尝试在我的脚本中构建哈希表。输入是一个参数:
Param
(
[hashtable]$param
)
调用我的函数:Foobar -Param 'Key, value'
不起作用。也试过:
Foobar -Param 'Key' = 'Value';
Foobar -Param Key Value
返回错误:Cannot convert value of type "System.String" to type "System.Collections.Hashtable".
如何正确传递参数?
使用哈希表文字 @{}
:
Foobar -Param @{ Key = 'Value' }