![]() ![]() ::Concat($Prepend, $RandomSymbolWord, $Append) ![]() $Append = Get-Random -InputObject $Numbers $Prepend = Get-Random -InputObject $Numbers $NumberedPassword = ForEach ($RandomSymbolWord in $RandomSymbolWords) ::Concat($Prepend, $RandomCaseWord, $Append) $Append = Get-Random -InputObject $Symbols $Prepend = Get-Random -InputObject $Symbols $RandomSymbolWords = ForEach ($RandomCaseWord in $RandomCaseWords) $ChangeCase = Get-Random -InputObject $True,$False $RandomCaseWords = ForEach ($RandomWord in $RandomWords) $RandomWord = $Dictionary | Select -Index $WordIndex $WordIndex = ($Random.GetBytes($RandomBytes)) $RandomSeed = $Random.GetBytes($RandomBytes) #I don't know why but when the below line is commented out, the function breaks and returns the same words each time. ![]() $RandomBytes = New-Object -TypeName 'System.Byte' 4 $MaxWordIndex = Get-Content -Path $DictionaryPath | Measure-Object -Line | Select -Expand Lines $Dictionary = Get-Content -Path $DictionaryPath $DictionaryPath = ('C:\Scripts\Words_' $WordLength '.txt') $RandomWords = ($WordLength in $WordLengths) #PICK WORD FROM DICTIONARY MATCHING RANDOM LENGTHS $WordLength = $MinWordLength $RandomNumber % $WordLength = ($Random.GetBytes($RandomNumber)) $WordLengths = $Words=1 $Words -le $WordCount $Words ) Thanks in advance and let me know if you have any feedback. There is one point of confusion for me here (details on Line 108, if any smart people are curious) basically the whole comment out something and it stops working when it shouldn't thing I hear is common. I have also done some neatening up and miscellaneous cleanup such as implementing /u/BoredComputerGuy's suggestion for the Case Change. You can download an Archive with all of them (which should be extracted to C:\Scripts\) here. I combined everything 24 characters into 24 since there wasn't enough to warrant them being separate. Methodology for splitting the files using PS is at the bottom. This does have the downside of requiring more files, but I think the offset is worth it. Picking by index (again, avoiding evaluation and calculation of length.txt files so as to both decrease unnecessary reads, and eliminate the required calculation. Splitting the dictionary into multiple pre-sorted.This was improved by two things, I believe. ![]() It now takes less than 10 seconds, averaging 4 from my quick testing (down from 2-5 minutes) to generate a password. I also have improved the performance issue significantly. I used the following links to get a handle on that: here and here. I only used this for the lengths and word selection as I didn't think the symbol or number randomization warranted the effort. u/da_chicken had pointed out that Get-Random used System.Random which wasn't appropriate for a password generator so after some research and a fair amount of frustration I've got this to work using. This is a follow-up to my post yesterday, that you can find here. Research Triangle Powershell User Group remote-capable.Philadelphia PowerShell User Group remote-capable.Madison Power Users Group remote-capable.Denver Microsoft Enterprise Management User Group.NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions. Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Submission Guidelines | Link Flair - How To ![]()
0 Comments
Leave a Reply. |