Generating Random Passwords

by Jun 11, 2013

If you need a simple way of creating random passwords, then this piece of code may help you:

$Assembly = Add-Type -AssemblyName System.Web

[System.Web.Security.Membership]::GeneratePassword(10,4)

GeneratePassword() takes two arguments. The first sets the length of the password. The second sets the number of non-alphanumeric characters that you want in it.

Twitter This Tip! ReTweet this Tip!