public/Merge-PasswordCharsets.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
$passwordCharSets = @{ LatinAlphaUpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; LatinAlphaLowerCase = "abcdefghijklmnopqrstuvwxyz"; Digits = "0123456789"; Hyphen = "-"; Underscore = "_"; Brackets = "[]{}()<>"; Special = "~`&%$#@*+=|\/,:;^"; SpecialHybrid = "_-#|^{}$"; Space = " "; } function Merge-PasswordCharSets() { [cmdletbinding()] Param( [ValidateSet('LatinAlphaUpperCase', 'LatinAlphaLowerCase', 'Digits', 'Hyphen', 'Underscore', 'Brackets', 'Special', 'Space', "SpecialHybrid")] [Parameter()] [string[]] $CharSets ) if($null -eq $CharSets -or $CharSets.Length -eq 0) { return $null } $result = $null; $sb1 = New-Object System.Text.StringBuilder foreach($setName in $CharSets) { if($passwordCharSets.ContainsKey($setName)) { $characters = $passwordCharSets[$setName]; $sb1.Append($characters) | Out-Null } } $result = $sb1.ToString(); return $result; } |