Hopefully easy ![]()
$string = "12345678"
how do i shuffle said sting to produce a random arrangement ? i.e numbers come out as 153264987?
Hopefully easy ![]()
$string = "12345678"
how do i shuffle said sting to produce a random arrangement ? i.e numbers come out as 153264987?
($string -split '' | Sort-Object {Get-Random}) -join ''
Thanks Olaf
oneliner contest ? ![]()
($string.ToCharArray() | Get-Random -Count $string.Length) -join ‘’
Olaf and Max
Thank you!! I was thinking I would need to loop through the string I needed to shuffle. You guys rock!
Depending on what you are doing, another option may be a range as well:
PS C:\WINDOWS\system32> Get-Random -Minimum 100000000 -Maximum 199999999 156910726 PS C:\WINDOWS\system32> Get-Random -Minimum 100000000 -Maximum 199999999 170770366 PS C:\WINDOWS\system32> Get-Random -Minimum 100000000 -Maximum 199999999 169781938
Here for the oneliner contest! ![]()
-join($string -split''|sort{Get-Random}) 39 characters. :D