- Joined
- Nov 11, 2010
I routinely make passwords and was looking through some of the pre-existing generators and thought I would do the same thing in Powershell as a learning exercise.
The script allows you to:
1- Create any length password
2 - Weight the password generation towards one of 4 categories (Uppercase, Lowercase, Numbers, or Special Characters)
3 - Copies it to your clipboard
The script allows you to:
1- Create any length password
2 - Weight the password generation towards one of 4 categories (Uppercase, Lowercase, Numbers, or Special Characters)
3 - Copies it to your clipboard
Code:
cls
write-host "This script will generate a weighted, randomized password"
write-host "You may assign a "weight" to one of the 4 types of characters used"
Write-Host "so that your password is more personalized"
Read-Host 'Press Enter to continue…' | Out-Null
$sdt0 = Read-Host 'How many total characters do you want the password to contain? : '
$Sdt1 = Read-Host 'How many lowercase letters do you want? : '
$Sdt2 = Read-Host 'How many upper case letters do you want? : '
$Sdt3 = Read-Host 'How many numbers do you want? : '
$Sdt4 = Read-Host 'How many special characters do you want? : '
$s1=(-join ('gmxeustahfwkzrvndcyb'.ToCharArray() | Get-Random -Count $Sdt1))
$s2=(-join ('HXULRMTNGSEVPWAFCZKBDY'.ToCharArray() | Get-Random -Count $Sdt2))
$s3=(-join ('7950281346'.ToCharArray() | Get-Random -Count $Sdt3))
$s4=(-join ("{|}/>(<&*,!@;+#[]\~.):?%$'".ToCharArray() | Get-Random -Count $Sdt4))
$str=$s1+$s2+$s3+$s4
-join ($str.ToCharArray() | Get-Random -Count $sdt0) | clip
Write-Host "The password has been copied to your clipboard."