Can’t Decide? Use Get-Random

Ever needed to choose a random value?

$choice = @(“Choice 1”, “Choice 2”); $i=0; while ($i -lt 10) {Get-Random $choice ; $i++}

This simply takes an array containing the available choices (choice 1 or choice 2 in this case) and loops through 10 times and uses Get-Random to randomly pick one of those 2 choices. You could easily adjust this to choose from a much larger number of options if you like.


No comments yet.

Leave a Reply