The answer to this is likely to be trivial, but I spent half an hour and still can not solve it.
Suppose I have the following hash table:
$hash = @{face='Off';}
What I tried to do displays the value "face" along some other string elements.
It works:
Write-Host Face $hash['face'] => Face Off
However, it is not:
Write-Host Face/$hash['face'] => Face/System.Collections.Hashtable[face]
Somehow, the absence of a space affected the operatorβs priority - now it evaluates the $ hash as a string, then the [face] concatenation.
Trying to solve this problem, I tried:
Write-Host Face/($hash['face']) => Face/ Off
Now I have extra space that I donβt want. This works, but I donβt want the extra line to just re-start:
$hashvalue = $hash['face'] write-host Face/$hashvalue => Face/Off
Any idea how to make this work as a single line?
source share