Author Posts

April 13, 2017 at 10:03 am

Hopefully easy 🙂


$string = "12345678"

how do i shuffle said sting to produce a random arrangement ? i.e numbers come out as 153264987?

April 13, 2017 at 10:16 am

($string -split '' | Sort-Object {Get-Random}) -join ''

April 14, 2017 at 9:02 am

oneliner contest ? 🙂
($string.ToCharArray() | Get-Random -Count $string.Length) -join "

June 18, 2018 at 1:31 pm

Olaf and Max

Thank you!! I was thinking I would need to loop through the string I needed to shuffle. You guys rock!

June 18, 2018 at 4:04 pm

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

June 18, 2018 at 4:10 pm

Here for the oneliner contest! 😉

-join($string -split''|sort{Get-Random})

39 characters. 😀