mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-10 10:34:54 +02:00
Renamed to list-passwords.ps1
This commit is contained in:
parent
9699b7e29b
commit
754a5c1899
@ -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-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-cmdlets.ps1](Scripts/list-cmdlets.ps1) - lists the PowerShell cmdlets
|
||||||
* [list-modules.ps1](Scripts/list-modules.ps1) - lists the PowerShell modules
|
* [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
|
* [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-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
|
* [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
|
* [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
|
* [moon.ps1](Scripts/moon.ps1) - prints the current moon phase
|
||||||
* [open-browser.ps1](Scripts/open-browser.ps1) - starts the default Web browser
|
* [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)
|
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (needs administrator rights)
|
||||||
* [news.ps1](Scripts/news.ps1) - prints the latest news
|
* [news.ps1](Scripts/news.ps1) - prints the latest news
|
||||||
* [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (needs administrator rights)
|
* [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (needs administrator rights)
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
#!/snap/bin/powershell
|
#!/snap/bin/powershell
|
||||||
|
|
||||||
# Syntax: ./passwords.ps1
|
# Syntax: ./list-passwords.ps1
|
||||||
# Description: generates and prints a list of new passwords
|
# Description: generates and prints a list of new passwords
|
||||||
# Author: Markus Fleschutz
|
# Author: Markus Fleschutz
|
||||||
# Source: github.com/fleschutz/PowerShell
|
# Source: github.com/fleschutz/PowerShell
|
||||||
# License: CC0
|
# License: CC0
|
||||||
|
|
||||||
$NumPasswords = 20
|
|
||||||
$CharsPerPassword = 15
|
$CharsPerPassword = 15
|
||||||
$MinCharCode = 33
|
$MinCharCode = 33
|
||||||
$MaxCharCode = 126
|
$MaxCharCode = 126
|
||||||
|
$NumLines = 24
|
||||||
|
$NumColumns = 6
|
||||||
|
|
||||||
function new_password() {
|
function new_password() {
|
||||||
$password = ""
|
$password = ""
|
||||||
@ -21,9 +22,12 @@ function new_password() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for ($j = 0; $j -lt $NumPasswords; $j++) {
|
for ($j = 0; $j -lt $NumLines; $j++) {
|
||||||
|
for ($k = 0; $k -lt $NumColumns; $k++) {
|
||||||
$password = new_password
|
$password = new_password
|
||||||
write-output $password
|
Write-Host -NoNewline "$password "
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
}
|
}
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} 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
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user