Generate Random Passphrase Passwords with PowerShell

This script builds a random passphrase by pulling words, numbers, and special characters from CSV wordlists and concatenating them until the result hits a minimum length of 15 characters. It's useful when you need a human-readable but policy-compliant password without reaching for a third-party tool.

How It Works

Load the Word Lists

Three CSV files are imported at runtime — one for words, one for numbers, one for special characters. Each CSV is expected to have a single named column matching its type (Word, Number, Special). The script uses System.Random to pick random indexes from each list.

Build the Initial Passphrase

Two words, a number, and a special character are picked and concatenated into a starting passphrase. No separators, no capitalization logic — just raw string concatenation. The result might look like tablerock7!.

Enforce Minimum Length

If the initial passphrase is under 15 characters, a while loop keeps appending additional word+number+special combos until the length requirement is satisfied. This handles cases where short words from the list produce an under-spec result on the first pass.

Output

The final passphrase is printed to the console between a pair of dashed dividers. Nothing is written to a file or clipboard — display only.

Usage

Dependencies

Three CSV files must exist at the hardcoded paths before the script will run:

C:\stuff\Scripts\words.csv
C:\stuff\Scripts\numbers.csv
C:\stuff\Scripts\specials.csvCode language: Bash (bash)

Each file needs a header row matching the expected column name. Example structures:

# words.csv
Word
table
river
hammerCode language: Bash (bash)
# numbers.csv
Number
7
42
301Code language: Bash (bash)
# specials.csv
Special
!
@
#Code language: Bash (bash)

Running the Script

No parameters. Just execute it directly:

.GeneratePassphrase.ps1Code language: PowerShell (powershell)

Permissions

Standard user rights are fine. No elevated privileges required. Script execution policy must allow local scripts — check with Get-ExecutionPolicy and adjust if needed.

Caveats

  • Paths are hardcoded. If the CSVs aren’t at C:stuffScripts, the script throws and stops. Parameterize the paths or update them before deploying to other machines.
  • $specials gets overwritten. The variable name $specials is used for both the imported CSV object and the randomly selected value. After the first random pick, the original list is gone. The while loop re-uses the same overwritten variable to pick from, which means it’s pulling from a single string, not the full list. New specials in the loop are always the same character that was picked initially. If variety in special characters matters to you, rename one of those variables.
  • System.Random is not cryptographically secure. For anything beyond internal tooling or temporary passwords that get changed on first login, use System.Security.Cryptography.RNGCryptoServiceProvider instead.
  • No complexity guarantees beyond length. The script doesn’t enforce uppercase, a minimum number of specials, or digit count. Whether the output passes your org’s password policy depends entirely on what’s in your CSVs and the luck of the draw.
  • Output is console-only. There’s no copy-to-clipboard or logging. If you’re generating passwords for bulk use, you’ll want to wrap this in a loop and redirect output to a file.

Full Script

Clear-Host
$rand = new-object System.Random
$words = import-csv "C:stuffScriptswords.csv"
$numbers = import-csv "C:stuffScriptsnumbers.csv"
$specials = import-csv "C:stuffScriptsspecials.csv"
$word1 = ($words[$rand.Next(0,$words.Count)]).Word
$word2 = ($words[$rand.Next(0,$words.Count)]).Word
$number = ($numbers[$rand.Next(0,$numbers.Count)]).Number
$specials = ($specials[$rand.Next(0,$specials.Count)]).Special
$Passphrase = $word1 + $word2 + $number + $specials

while ($Passphrase.length -lt 15){
$word3 = ($words[$rand.Next(0,$words.Count)]).Word
$number = ($numbers[$rand.Next(0,$numbers.Count)]).Number
$specials = ($specials[$rand.Next(0,$specials.Count)]).Special

$Passphrase = $Passphrase + $word3 + $number + $specials
}
"Random Generated Password :"
"---------------------------"
Write-Host $Passphrase
"---------------------------"
"                           "Code language: PowerShell (powershell)

📄 Companion Files