Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How to pipe hash table values into a variable

$
0
0

I'm setting up a few hash tables so that i'm able to use the key values within a script. I have setup the hash key values as below. I prompt the user to enter a hash table. Let's say they they enter $Jungle. Now the $selectedapp should equate to $Jungle. If i run the command write-host $selectedapp.Louise, i should see results of Ubuntu, but i do not see anything - blank output. So something is not written up correctly. If i instead replace the "Read-Host" directly with $Jungle, i.e $selection = $Jungle, then the command write-host $selectedapp.Louise successfully outputs Ubuntu. What am i doing wrong? Thanks

 

$CompHash = @{Jasmine ="Win7"; Louise="Vista"; Mary="XP"}

$Jungle = @{Jasmine ="Macintosh"; Louise="Ubuntu"; Mary="Redhat"}

$selection = Read-Host

$selectedapp = $selection

write-host $selectedapp.Louise


Viewing all articles
Browse latest Browse all 6937

Trending Articles