Most password apps have built in generators. I generate my own passwords for things I automate on my systems, like rotating passwords for whatever, which I store in my own vaults. This is an example, or one way to do it. You could make it more complex, where you only have words that don’t get chopped to make things easier to remember, but this is for automated processes and I don’t really need to care.
Here’s the script.
PowerShell
x
49
49
1
$Arg = Read-Host "Password length"
2
$MaxLen = [int]$Arg
3
4
<#
5
I am pointing to the dictionary on Linux (Ubuntu).
6
You may need to install a dict or point to another path.
7
8
This code should work on Windows and Mac also, just get a
9
dictionary file and change the path below.
10
11
FreeDict: https://freedict.org/downloads/
12
#>
13
$DWords = Get-Content /usr/share/dict/words
14
15
$RWorks = $DWords | Get-Random -Count 500 # Adjust count as you see fit.
16
17
# Add or remove special chars here.
18
$SpecialChars = @("1","2","4","5","6","7","8","9","&","*")
19
20
$Gen = ""
21
ForEach ($word in $RWorks) {
22
23
$word = $word.ToLower()
24
$Char = $SpecialChars | Get-Random
25
$word = $word.Replace("'","") + $Char + "-"
26
$Letter = $word[0]
27
28
<# I like to replace some chars. to make passwords more complex.
29
You can comment the following five lines if you want your
30
passwords clearer. #>
31
$word = $word.Replace("e","3")
32
$word = $word.Replace("s","$")
33
$word = $word.Replace("a","@")
34
$word = $word.Replace("o","0")
35
$word = $word.Replace("i","!")
36
37
$Gen += $word.Replace($Letter, $Letter.ToString().ToUpper())
38
39
if ($Gen.Length -ge $MaxLen) {
40
$Gen = $Gen.SubString(0,$MaxLen)
41
if ($Gen.EndsWith("-")) {
42
$Gen = $Gen.Trim().TrimEnd('-')
43
$Gen = $Gen + $Char
44
}
45
break
46
}
47
}
48
49
Write-Host $Gen #$Gen.Length