Generating a random password with PowerShell
Instead of bashing on the keyboard, I’m a proponent of using a tool to generate a random password, such as when creating a service account or new user accounts. A colleague of mine recently discovered that this is doable with Windows PowerShell, in only two lines!
Add-Type -Assembly System.Web
This will return a string using the provided parameters. For example, setting $length = 15 and $numberOfNonAlphanumericCharacters = 6 the output is
(You get the idea.)
MSDN provides more detail on the GeneratePassword method. Sadly it only allows up to 128 characters in length.