Monday, December 3, 2012

A defect for 'get-random'

In PS 3.0, 'Get-random' doesn't return an error value for a $null variable without the use of  '-inputobject'.  I came across this writing a  function so my third grader could pick up her arithmetic skills. The function has '$Mixed' as such:

[array]$Mixed= % {
0..($questions_per_worksheet - 1) | % {write "2 $operator1 $(get-random -max $random_max -min $random_min) = "} 
0..($questions_per_worksheet - 1) | % {write "4 $operator2 $(get-random -max $random_max -min $random_min) = "} 
0..($questions_per_worksheet - 1) | % {write "5 $operator3 $(get-random -max $random_max -min $random_min) = "} 
0..($questions_per_worksheet - 1) | % {write "10 $operator4 $(get-random -max $random_max -min $random_min) = "}