PSTip: Get-Random

Please Visit: http://ift.tt/1ajReyV



PSTip: Get-Random

http://ift.tt/1ayvQMJ

1..5 | % { (1..49 | Get-Random -Count 6) -join (",") }

when 1..6 | Get-Random -Count 6 cannot display duplicates

do { if( ($num=(Get-Random -Minimum 1 -Maximum 7) ) -notin $nums ){ [int[]]$nums+=$num } } while ( $nums.count -lt 6 ) $nums

the syntax does not support -Count and -Minimum or -Maximum parameters together.

Get-Random -minimum 1 -maximum 101

you can use Get-Random to randomly select from a list of names:

($a = "Dasher","Dancer","Prancer","Vixen","Comet","Cupid","Donder","Blitzen" ) | Get-Random

Get-Random -input "Dasher","Dancer","Prancer","Vixen","Comet","Cupid","Donder","Blitzen"

($a = "Dasher","Dancer","Prancer","Vixen","Comet","Cupid","Donder","Blitzen" ) | Get-Random -count 3

1..10 | % {Get-Random -Minimum 2 -Maximum 20 } | Sort -Unique

1..4 | % { Get-Random -Minimum 1 -Maximum 30 }

$users = gc C:\fso\UserGroupNames.txt

$users | Get-Random -Count $users.Count



from Google Plus RSS Feed for 101157854606139706613 http://ift.tt/1kZzzEe

via LifeLong Community

No comments:

Post a Comment