So im definitely close to exactly what im looking for on this. Basically, I have users, and for security purposes, I want their usernames to be randomly generated 7 character SIDs.
example: rgf8uwt or euw2prt or wif5llc
basically it would be 3 letters, then 1 number then 3 more letters
So im trying to create a random generator to do this and what I have so far is:
#to create the random number
-join ((48..57) | get-random -Count 1 | % {[char]$_})
#to create the random 3 letter string
-join ((97..122) | Get-Random -Count 3 | % {[char]$_})
So now where im stuck is merging the 2 together is a way that it generates a string of characters that is 7 long, with 3 letters, then 1 number, and then 3 letters.
Unless theres a better way to do this that i just dont know about.
CodePudding user response:
With a it seems to work
$Part1 = -join ((97..122) | Get-Random -Count 3 | % {[char]$_})
$Part2 = -join ((48..57) | get-random -Count 1 | % {[char]$_})
$Part3 = -join ((97..122) | Get-Random -Count 3 | % {[char]$_})
$Part1 $Part2 $Part3