LightningWar
LightningWar

Reputation: 975

Using hash table parameter in function

I'm trying to build a hashtable in my script. Input is a parameter:

Param
(
[hashtable]$param
)

calling my function: Foobar -Param 'Key, value' does not work. Also tried:

Foobar -Param 'Key' = 'Value';
Foobar -Param Key Value

Error returned: Cannot convert value of type "System.String" to type "System.Collections.Hashtable".

How do I pass the arguments correctly?

Upvotes: 1

Views: 1804

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174485

Use a hashtable literal @{}:

Foobar -Param @{ Key = 'Value' }

Upvotes: 1

Related Questions