One-Liner: Generate a Random Password
Always learning. Forever delighted. Happily surprised.
That's using PowerShell for you... well, me.
The other week one of my customers showed me this little beauty:
[System.Web.Security.Membership]::GeneratePassword(20,5)
The GeneratePassword static method accepts two values: the first parameter is the number of characters in the generated password; the second parameter is the number of non-alphanumeric characters to include.
With the above one-liner we get a 20 character password with 5 non-alphanumeric characters. For example:
This has replaced the lengthy New-Password function I had in my $profile...