Monthly Archive


Playing with the range operator

The range operator allows you to reference a range of numbers



is equivalent to



If you want anything other than numbers you’re stuck as the range operator only works with integers

though you can have a decrementing list



65..74 | foreach {[char]$psitem}

would be A – J


If you want A-Z

65..90 | foreach {[char]$psitem}


For lowercase letters (a – z)  use

97..122 | foreach {[char]$psitem}


You can even work from an array of values

$data = 'value1','value2','value3','value4','value5','value6','value7','value8','value9','value10'


Comments are closed.