Less Awful AD Account Creation w/ Powershell!

Less Awful AD Account Creation w/ Powershell!
Photo by Andre Hunter / Unsplash

I work in K12 Education. Student accounts in AD and Google Workspace are automatically provisioned with the help of Classlink's OneSync. Staff accounts on the other hand, are much more difficult to automate, as their are many different positions with different needs. Those have historically been created by hand. This leads to a slew of misspellings, incorrect groups, duplicate accounts, and other random human errors that has, at worst, caused actual data loss when profile folders were overwritten. Yikes.

With that in mind, I took it upon myself to create a script (A rather opinionated one at that...) that makes this manual process a bit more cohesive.

As of right now, it does the following:

  1. Request Administrator elevation
  2. Prompt for the User's First Name.
  3. Prompt for the User's Middle Initial.
  4. Prompt for the User's Last Name
  5. Prompt for the User's Position (Job title)
  6. Prompt for the User's Location (Building)
  7. Generate a Display Name, UPN, OU, Email address, Home Folder location, and 8. Data Group name.
  8. Verify there are no other users with the same unique attributes. Exit if so.
  9. Verify that the Data group exists, warn if not.
  10. Generate a unique one-time password just for account creation.
  11. Create User.
  12. Add user to groups.

The code itself, along with a much more in-depth explanation, is available here at my GitLab:

Joshua Martin / AD Account Creator - Powershell · GitLab
GitLab.com

https://gitlab.com/JoshuaCMartin/ad-account-creator-powershell