mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 05:04:39 +02:00
Renamed to list-passwords.ps1
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
#!/snap/bin/powershell
|
||||
|
||||
# Syntax: ./passwords.ps1
|
||||
# Syntax: ./list-passwords.ps1
|
||||
# Description: generates and prints a list of new passwords
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
$NumPasswords = 20
|
||||
$CharsPerPassword = 15
|
||||
$MinCharCode = 33
|
||||
$MaxCharCode = 126
|
||||
$NumLines = 24
|
||||
$NumColumns = 6
|
||||
|
||||
function new_password() {
|
||||
$password = ""
|
||||
@ -21,9 +22,12 @@ function new_password() {
|
||||
}
|
||||
|
||||
try {
|
||||
for ($j = 0; $j -lt $NumPasswords; $j++) {
|
||||
$password = new_password
|
||||
write-output $password
|
||||
for ($j = 0; $j -lt $NumLines; $j++) {
|
||||
for ($k = 0; $k -lt $NumColumns; $k++) {
|
||||
$password = new_password
|
||||
Write-Host -NoNewline "$password "
|
||||
}
|
||||
Write-Host ""
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
@ -1,29 +0,0 @@
|
||||
#!/snap/bin/powershell
|
||||
|
||||
# Syntax: ./password.ps1
|
||||
# Description: generates and prints a single new password
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
$CharsPerPassword = 15
|
||||
$MinCharCode = 33
|
||||
$MaxCharCode = 126
|
||||
|
||||
function new_password() {
|
||||
$password = ""
|
||||
$generator = New-Object System.Random
|
||||
for ($i = 0; $i -lt $CharsPerPassword; $i++) {
|
||||
$password = $password +[char]$generator.next($MinCharCode,$MaxCharCode)
|
||||
}
|
||||
return $password
|
||||
}
|
||||
|
||||
try {
|
||||
$password = new_password
|
||||
write-output $password
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user