All,
I had a question in regards to the switch statement and hash tables. I know with a switch statement you can do an array like so
$a = 21, 38, 6
switch ($a)
{ 1 {"The color is red."}
2 {"The color is blue."}
3 {"The color is green."}
4 {"The color is yellow."}
5 {"The color is orange."}
6 {"The color is purple."}
7 {"The color is pink."}
8 {"The color is brown."} }
I actually have found an example that I use to evaluate a hash table based on the $_.name value
$myHash = @{}
$myHash["a"] = 1
$myHash["b"] = 2
$myHash["c"] = 3
switch ($myhash.GetEnumerator())
{ {$_.name -like ‘*a*’ } {"It is a"} }
What I want to understand is how does the curly braces know to do a comparison on the $_.name variable? How come you don't have to use the Where statement? I didn't find any documentation on the swtich statement that went over hash tables. IS there an advanced guide for powershell on syntax for things like this?
Also, is there a good powershell forum out there? google only shows technet and I'm not a big fan of that format.