Q. What's a good way to create a secure, random password in PowerShell?
Q. What's a good way to create a secure, random password in PowerShell? A. Previously, I explained how to create a password using random characters generated by the System.Random object, butthis may not be secure enough.
September 15, 2015
Q. What's a good way to create a secure, random password in PowerShell?
A. Previously, I explained how to create a password using random characters generated by the System.Random object, but this may not be secure enough.
So try this method: Use the GeneratePassword method of System.Web.Security.Membership, which enables a number of characters for the new password to be specified and the number of special characters that are required within the new password. Here's where this is documented.
To use this in PowerShell use:
Add-Type -AssemblyName System.Web
[System.Web.Security.Membership]::GeneratePassword(16,2)
You can save the output to a variable then use as needed.
About the Author
You May Also Like