Created
May 28, 2016 06:11
-
-
Save anonymous/530cd44b91e599eed08fd15f70556bc2 to your computer and use it in GitHub Desktop.
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
<# | |
.Synopsis | |
Short description | |
.DESCRIPTION | |
Long description | |
.EXAMPLE | |
Example of how to use this cmdlet | |
.EXAMPLE | |
Another example of how to use this cmdlet | |
#> | |
function get-randompassword | |
{ | |
[CmdletBinding()] | |
[Alias()] | |
[OutputType([int])] | |
Param | |
( | |
# Param1 help description | |
[Parameter( | |
ValueFromPipelineByPropertyName=$false, | |
Position=0)] | |
[int] | |
$UppercaseAlphachracters=3, | |
[int] | |
$LowercaseAlphaChracters=3, | |
# Param2 help description | |
[int] | |
$SpecialChracters=3, | |
$NumericChracters=3 | |
) | |
Begin | |
{ | |
Write-Host 'Begin: Setting up Randommization Arrays' -ForegroundColor Yellow | |
$sc = @() | |
$in = @() | |
$L = @() | |
[string] $pw = @() | |
[string] $uc = @() | |
[string] $Lc = @() | |
[string] $nu = @() | |
Write-Host 'END: Setting up Randommization Arrays' -ForegroundColor Yellow | |
} | |
Process | |
{ | |
Write-Host 'Begin: Setting up Alphanumeric and Special Chracter Values' -ForegroundColor Yellow | |
$L += 'a' ; $L += 'b' ; $L += 'c' | |
$L += 'd' ; $L += 'e' ; $L += 'f' | |
$L += 'g' ; $L += 'h' ; $L += 'i' | |
$L += 'j' ; $L += 'k' ; $L += 'l' | |
$L += 'm' ; $L += 'n' ; $L += 'y' | |
$L += 'o' ; $L += 'p' ; $L += 'q' | |
$L += 'r' ; $L += 's' ; $L += 't' | |
$L += 'u' ; $L += 'v' ; $L += 'w' | |
$L += 'x' ; $L += 'z' ; $in += '1' | |
$in += '2' ; $in += '3' ; $in += '4' | |
$in += '5' ; $in += '6' ; $in += '7' | |
$in += '8' ; $in += '9' ; $sc += '!' | |
$sc += '@' ; $sc += '#' ; $sc += '$' | |
$sc += '%' ; $sc += '^' ; $sc += '&' | |
$sc += '*' ; $sc += '(' ; $sc += ')' | |
$sc += '-' ; $sc += '_' ; $sc += '+' | |
$sc += '=' ; $sc += '`' ; $sc += '~' | |
$sc += '[' ; $sc += ']' ; $sc += '{' | |
$sc += '}' ; $sc += '\' ; $sc += '|' | |
$sc += '*' ; $sc += '/' ; $sc += '?' | |
$sc += ';' ; $sc += ':' ; $sc += "'" | |
$sc += '"' ; $sc += ',' ; $sc += '<' | |
$sc += '.' ; $sc += '>' ; $sc += '?' | |
Write-Host 'END: Setting up Alphanumeric and Special Chracter Values' -ForegroundColor Yellow | |
$cu=0 | |
$cl=0 | |
$cs=0 | |
$cn=0 | |
# $UppercaseAlphachracters = $UppercaseAlphachracters +1 | |
#$LowercaseAlphaChracters = $LowercaseAlphaChracters +1 | |
#$SpecialChracters = $SpecialChracters +1 | |
#$NumericChracters = $NumericChracters +1 | |
while ($cu -le $UppercaseAlphachracters -or $cl -le $LowercaseAlphaChracters -or $cs -le $SpecialChracters -or $cn -le $NumericChracters ){ | |
$cu ++ | |
$cl ++ | |
$cs ++ | |
$cn ++ | |
#randomize the placement of randomized values | |
$randomnumber = 1..4 | |
$randomnumberGR = $randomnumber | Get-Random | |
if ($randomnumberGR -eq '1'){ | |
if($cn -le $NumericChracters ) { | |
$pw += $in | Get-Random | |
} | |
if($cs -le $SpecialChracters){ | |
$pw += $sc | Get-Random | |
} | |
if ($cl -le $LowercaseAlphaChracters){ | |
$pw += $l | Get-Random | |
} | |
if ($cu -le $UppercaseAlphachracters){ | |
$pw += $l.toupper() | Get-Random | |
} | |
} | |
if ($randomnumberGR -eq '2' ){ | |
if ($cl -le $LowercaseAlphaChracters){ | |
$pw += $l | Get-Random | |
} | |
if ($cu -le $UppercaseAlphachracters){ | |
$pw += $l.toupper() | Get-Random | |
} | |
if($cs -le $SpecialChracters) { | |
$pw += $sc | Get-Random | |
} | |
if($cn -le $NumericChracters ) { | |
$pw += $in | Get-Random | |
} | |
} | |
if ($randomnumberGR -eq '3' ) { | |
if ($cu -le $UppercaseAlphachracters) { | |
$pw += $l.toupper() | Get-Random | |
} | |
if ($cl -le $LowercaseAlphaChracters){ | |
$pw += $l | Get-Random | |
} | |
if($cs -le $SpecialChracters) { | |
$pw += $sc | Get-Random | |
} | |
if($cn -le $NumericChracters ) { | |
$pw += $in | Get-Random | |
} | |
} | |
if ($randomnumberGR -eq '4' ) { | |
if ($cl -le $LowercaseAlphaChracters) { | |
$pw += $l | Get-Random | |
if ($cu -le $UppercaseAlphachracters) { | |
$pw += $l.toupper() | Get-Random | |
} | |
if($cs -le $SpecialChracters) { | |
$pw += $sc | Get-Random | |
} | |
if($cn -le $NumericChracters ) { | |
$pw += $in | Get-Random | |
} | |
} | |
` | |
} | |
} | |
} | |
end{$pw} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment