The simpluest thing would be to constuct an array of, say, 55 elements. Populate this with the letters a-z in upper and lowercase , the digits 0-9 and some (safe) punctuation characters to make up the balance. To eliminate confusion, I would exclude the letters 'o', 'l', 'O' and the digist 0 and 1. This just because they can appear quite similar in some fonts.
Now you can create a loop to pick elements from this array at random, building up a password. A password length of 6 - 8 should be ok.
If your system supports it, you might want to set the password to "expired" so that when the user logs in with the new password, they are immediately prompted to set it again to somethign meaningful to them.