PowerShell out-random function
Bruno left a comment on the post about my solution for Scripting Games 2008 Advanced Windows PowerShell Event 7 about my sort routine, using a scriptblock could make it even simpler, and so elegant I decided to make an extra post about it, a generic randomize function in PowerShell can be as easy as :
function out-random {
$r = New-Object random
$input | sort {$r.next()}
}
Sample usage :
PS C:\scripts> 1..10 | out-random
7
6
8
10
9
2
1
3
5
4
The Posh life can be so simple sometimes.
Enjoy,
Greetings /\/\o\/\/