Renamed to list-passwords.ps1

This commit is contained in:
Markus Fleschutz 2020-12-14 07:37:21 +00:00
parent 9699b7e29b
commit 754a5c1899
3 changed files with 10 additions and 36 deletions

View File

@ -17,6 +17,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [list-unused-files.ps1](Scripts/list-unused-files.ps1) - lists unused files in a directory tree
* [list-cmdlets.ps1](Scripts/list-cmdlets.ps1) - lists the PowerShell cmdlets
* [list-modules.ps1](Scripts/list-modules.ps1) - lists the PowerShell modules
* [list-passwords.ps1](Scripts/list-passwords.ps1) - generates and prints a list of new passwords
* [list-processes.ps1](Scripts/list-processes.ps1) - lists the local computer processes
* [locate-city.ps1](Scripts/locate-city.ps1) - prints the lat/long coordinates of the given city
* [locate-ipaddress.ps1](Scripts/locate-ipaddress.ps1) - locates the geographic position of the given IP address
@ -24,8 +25,6 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [make-install.ps1](Scripts/make-install.ps1) - installs built executables and libs to the installation directory
* [moon.ps1](Scripts/moon.ps1) - prints the current moon phase
* [open-browser.ps1](Scripts/open-browser.ps1) - starts the default Web browser
* [password.ps1](Scripts/password.ps1) - generates and prints a single new password
* [passwords.ps1](Scripts/passwords.ps1) - generates and prints a list of new passwords
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (needs administrator rights)
* [news.ps1](Scripts/news.ps1) - prints the latest news
* [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (needs administrator rights)

View File

@ -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 {

View File

@ -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
}