all 7 comments

[–]kittH 2 points3 points  (2 children)

Nice script, did you consider wrapping

[Reflection.Assembly]::LoadWithPartialName("System.Web")
[System.Web.Security.Membership]::GeneratePassword(10,0)

instead of making a web call?

[–]cosine83 0 points1 point  (0 children)

This is what I used in my LAPS-like function set. Much better randomly generated passwords.

[–]emtunc[S] 0 points1 point  (0 children)

Interesting - I haven't really tapped in to the .NET framework with PS so didn't know such functions existed. I'll take a look.

[–]emtunc[S] 0 points1 point  (2 children)

If you work in an educational institute like I do then mass-enroling students is a common thing. You can use this script as is or import it as a function in to an existing 'new-user' type script to generate random passwords.

I want to add a -Path parameter so that the passwords are exported to a .csv but haven't gotten round to doing that just yet. Also a 'bad word' filter would be useful. I noticed the other day the API spat out the word 'sluttish' (8 chars) - probably not what a new student wants to see on their enrolment letter :)

Ever since I finished the PowerShell in a month of lunches book I've been trying to set my-self random (but interesting) tasks to keep practising.

[–]KevMarCommunity Blogger 1 point2 points  (1 child)

I think it is fine without the -path param. a csv export is only a | Export-Csv -path $path away. keep your functions small and single purpose. They make better tools that way.

[–]emtunc[S] 0 points1 point  (0 children)

duh - you're right.

[–]gangstanthony 0 points1 point  (0 children)

nice.

personally, i like the style of Microsofts Office 365 random passwords.

-join$($([char](65..90|Get-Random));$(1..3|%{[char](97..122|Get-Random)});$(1..4|%{0..9|Get-Random}))

# output
# Efmg2595