Hi all,
I'm currently building a PowerShell function. Whilst I've done a lot of scripting before, I've never really created any functions, so I'm a bit of a newbie.
I'd like to be able to pass a hashtable to a function. I've written something basic to explain what I'm trying to do below:
$hashtable1 = @{"Name1"="Value1";"Name2"="Value2"} function hashfunction { Param($hash) foreach ($foo in $hash) { Write-Host $foo.value } } hashfunction -hash $hashtable1
This doesn't return anything.
I've tried specifying hashtable like this...
Param([hashtable]$hash)
...but didn't have any luck.
Can anyone please point me in the right direction? I've got the rest of my script working brilliantly, I'm just trying to turn it into a usable function!
Thanks,
Gavin
- Edited by Gavin Morrison Sunday, January 29, 2012 2:52 PM