Tuesday, May 19, 2015

User account creation script


I created a relatively complex Powershell script to manage creating new user accounts in our environment.

It handles the following:


  • Highly configurable with a separate config file to customize to your site
  • Creating the user in AD from a .csv file with just a few simple fields
    • User settings based on a template account--you can use a template for each department
    • User name and login name are automatically generated and guaranteed unique
  • Generates a random passphrase from a dictionary of your choice (sample is provided)
  • Setting up two network folders for the user -- a U: drive and an S: drive in our environment
  • Sets up AD variables that I use later for account archiving and setting defaults automatically with Group Policy for Office save locations, Outlook "home page" setting etc.
  • Activating for Office 365
  • Sending a welcome email message
  • Some applications specific to our office:
    • Activating proper permissions for Mimecast archiving
    • Setting up the account for the Esquire Innovations iCreate template database
  • A fair amount of error handling based on a few years of issues we ran into--handles race conditions, improper input in the names, etc.
  • Output of the script is saved to a .csv file designed to be imported into KeePass. 
  • A moderate amount of information is logged by default

This was designed to meet my own needs, but you can feel free to adapt it. I make use of the work of others, I started with a "Hey Scripting Guys" blog post from several years ago and heavily adapated it to make it more robust for our use and adapted the folder creation script as well.