PowerShell/Scripts/list-random-pins.ps1

29 lines
715 B
PowerShell
Raw Normal View History

2020-12-29 15:14:21 +01:00
<#
2021-04-07 15:17:49 +02:00
.SYNTAX list-random-pins.ps1 [<pin-length>] [<columns>] [<rows>]
2021-03-22 20:10:18 +01:00
.DESCRIPTION prints a list of random PIN's
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
2020-12-29 15:14:21 +01:00
#>
2020-12-22 10:12:50 +01:00
param([int]$PinLength = 5, [int]$Columns = 12, [int]$Rows = 26)
2020-12-22 10:12:50 +01:00
try {
write-output ""
$Generator = New-Object System.Random
2020-12-29 15:14:21 +01:00
for ($j = 0; $j -lt $Rows; $j++) {
2020-12-22 10:12:50 +01:00
$Line = ""
for ($k = 0; $k -lt $Columns; $k++) {
for ($i = 0; $i -lt $PinLength; $i++) {
$Line += [char]$Generator.next(48,57)
}
2020-12-22 10:12:50 +01:00
$Line += " "
}
write-output $Line
}
write-output ""
exit 0
} catch {
2021-05-02 21:30:48 +02:00
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-22 10:12:50 +01:00
exit 1
}