PowerShell/Scripts/list-pins.ps1

36 lines
722 B
PowerShell
Raw Normal View History

2020-12-29 15:14:21 +01:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
list-pins.ps1 [<pin-length>] [<columns>] [<rows>]
2021-07-13 21:10:02 +02:00
.DESCRIPTION
Prints a list of random PIN's
.EXAMPLE
PS> .\list-pins.ps1
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
2021-08-03 15:53:57 +02:00
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 = 30)
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
}