Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell - unable to read hash value

$
0
0

I am writing a simple script to get more familiar with powershell.

This script reads input parameters into a hash

$states = @($args)
$states
write-host Color is $states.color

On the command-line, I set the following values

$shape = 'circle'; $color = 'pink'; $size = 'large'

I then invoke the program with the following command

.\shapes_n_colors.ps1  $shape $size $color

And, I get the following output:

circle
large
pink
Color is

I am unable to figure out why $states.color is blank. I was expecting the output "Color is pink"

Where am I going wrong???


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>