Click here for important information about

[PowerShell] Password Generator

By: Kilavila
May 4, 2020

This is not really an how-to, but rather just sharing some useful code for anyone to use or edit.

Every week at work I need to create random temporary passwords for employees, so I found some random generator and made it better. This script will create passwords based on user input, and you can generate as many passwords as you want.

Aight, lets get to it:


$Lower = Read-Host -Prompt "How many lower case letters?"
$Upper = Read-Host -Prompt "How many upper case letters?"
$Number = Read-Host -Prompt "How many numbers?"
$Amount = Read-Host -Prompt "How many passwords?"
Write-Host ""
Write-Host "Generated passwords:"
Write-Host ""

foreach ($i in 1 .. $Amount)
function Get-RandomCharacters($length, $characters)
$random = 1 .. $length | ForEach-Object { Get-Random -Maximum $characters.length }
$private:ofs = ""
return [String]$characters[$random]

function Scramble-String([string]$inputString)
$characterArray = $inputString.ToCharArray()
$scrambledStringArray = $characterArray | Get-Random -Count $characterArray.Length
$outputString = -join $scrambledStringArray
return $outputString

$password = Get-RandomCharacters -length $Lower -characters 'abcdefghiklmnoprstuvwxyz'
$password += Get-RandomCharacters -length $Upper -characters 'ABCDEFGHKLMNOPRSTUVWXYZ'
$password += Get-RandomCharacters -length $Number -characters '1234567890'

$password = Scramble-String $password
Write-Host $password

Write-Host ""
Read-Host "Press ENTER to close this script"


No editing needed: Just copy, paste, save and run it...

Hope you learned something new and good luck with your scripting!
Your friendly neighborhood potato Kilavila

Need more help?
Describe your Problem
Example: Hard Drive Not Detected on My PC

Ask Question