Created
March 29, 2016 13:05
-
-
Save michaelrice136/f14d5d3f2dff56eff73c to your computer and use it in GitHub Desktop.
Generate a new password using PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Password ($length) | |
{ | |
[string]$Password = '' | |
[array]$lower = @('a','b','c','d','e','f','g','h','i','j','k','l','n','m','n','o','p','q','r','s','t','u','v','w','x','y','z') | |
[array]$upper = @('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') | |
[array]$symbol = @('!','"','£','$','%','^','&','*','(',')',',','.','@','#') | |
[array]$num = @('1','2','3','4','5','6','7','8','9','0') | |
[array]$rand = @($lower,$upper,$symbol,$num) | |
for ($i = 1; $i -lt $length+1; $i++) | |
{ | |
$RandChar = Get-Random -InputObject (Get-Random -InputObject $rand) | |
$Password += $RandChar | |
} | |
return $Password | |
} | |
#Use New-Password 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment