PowerShell function to generate a random password

This is part of one of my AD migration scripts which I find very useful.
Whenever creating a user, I like to generate a random and complex password. The length of the password differs for each of my customers, so that’s something I define with a parameter added to this function:

Note that this one is very basic, no check in there for when both a higher- and lower case character, number and/or punctuation mark is included. For most of my customers the function above is sufficient I Hope you find this one useful

Update: Changed the script based on feedback from Shay Levy through Twitter… thanks! 😀