I was looking for PowerShell solutions for generating a random password (in
order to set the Administrator password on a Windows instance provisioned in
OpenStack), and found several solutions using the GeneratePassword method
of System.Web.Security.Membership
(documentation here),
along the lines of this:
Function New-RandomComplexPassword ($length=8)
{
$Assembly = Add-Type -AssemblyName System.Web
$password = [System.Web.Security.Membership]::GeneratePassword($length,2)
return $password
}
While this works, I was unhappy with the generated passwords: they were difficult to type or transcribe because they make heavy use of punctuation. For example: