I want to generate 10k of unique numbers composed of a sequential number (16 digits) followed by a random numeric string (4 digits). Weapon of choice is Powershell because it's the only tool I have a very limited knowledge of.
Problems encountered:
Get-Random -Minimum 0001 -Maximum 9999
and putting them in a variable. I manage only to obtain 1 random number.How can I combine these 3 commands to obtain a list of semi random numbers as specified above? Or is there simpler way to achieve the same result?
(0..10000).ForEach{ '14000000000{0:00000}{1:0000}' -f $_, (Get-Random 10000) }
Result:
14000000000000004965
14000000000000010114
14000000000000026382
14000000000000038644
14000000000000045435
14000000000000052051
14000000000000061801
14000000000000077046
14000000000000087791
14000000000000098090
14000000000000102712
....
Explanation:
-f
) to format the string, like '14000000000{0:00000}{1:0000}'
. For details, see composite formatting.[int32]
, just count from 0..1000
with leading zeros up to 5 digits ({0:00000}
) and prefix it with 14000000000
{1:0000}
), place a new random number with leading zeros up to 4 digits