I needed an easy way to create users in Active Directory.
PowerShell to the rescue … although it didn’t work out.
The PowerShell command New-ADUser depends on AD having web services enabled which is a feature that came out with 2008 R2 – needless to say the AD server I was working with didn’t have this. So I fell back to the good old fashioned command line: dsadd user.
I put together an excel with columns like this:
1 2 3 4 5 6 7 |
A - Company Name B - User Prefix C - First Name D - Last Name E - Email Address F - Password G - a formula to generate the command using data in the row ... |
1 |
=CONCATENATE("dsadd user ""CN=", C2, " ", D2, ",OU=users,OU=my,DC=dc,DC=path"" -samid """, B2, "-", D2, """ -upn """, B2, "-", D2, "@dc.path"" -pwd """, F2, """ -fn """, C2, """ -ln """, D2, """ -email """, E2, """ -desc """, A2, " - User"" -d ""dc.path"" -display """, C2, " ", D2, """") |
So for this data
1 2 3 4 5 6 |
A - acme corp B - acme C - John D - Smith E - John.Smith@AcmeCorp.com F - Password1 |
The following command is generated:
1 |
dsadd user "CN=John Smith,OU=users,OU=my,DC=dc,DC=path" -samid "acme-Smith" -upn "acme-Smith@dc.path" -pwd "Password1" -fn "John" -ln "Smith" -email "John.Smith@AcmeCorpm.com" -desc "acme corp - User" -d "dc.path" -display "John Smith" |
This is going to save me minutes – literally minutes – every month!