I am trying to pass user input to hashTable, which I am attempting to do.
$someHash =
@{
1 = "one";
2 = "two";
3 = "three"
}
$x = Read-Host "enter 1,2,3"
Write-Output($someHash.$x)
For some reason $someHash.$x and $someHash[$x] return null, but $x has it value.
I also can get values out of the map when I hard code keys. Not sure what I am doing incorrectly.
Adding to address comments. I have also tried casting with the same result.
$someHash.[int]$x
$someHash[[int]$x]
[int]$x = Read-Host "enter 1,2,3"
I have also used strings as keys using single and double-quotes. Same outcome.