PowerTip: Select Two Random Numbers from 20 Possibilities


Summary: Use Windows PowerShell to select two random numbers from twenty possible numbers.

Hey, Scripting Guy! Question How can I use Windows PowerShell to select two of twenty attendees at user group to receive prizes?

Hey, Scripting Guy! Answer Create a range of input numbers with the Get-Random cmdlet, then use the –Count parameter to retrieve
           two random numbers:

Get-Random -InputObject (1..20) -Count 2

Comments (2)

  1. Unicorn02 says:

    That’s not really working as it should, as it is possible that 2 times the same random number might be picked

  2. Unicorn02 says:

    Sorry, but I have to correct. This actually works as it should! PowerShell Rulez!!!!

Skip to main content