I’ve got a bit of a love-hate relationship with Powershell, but in this case it’s turned into a bit of love. Importing users with Powershell is relatively easy to do when combined with ActiveRoles Management Shell for Active Directory, from Quest, which adds a handful of rather useful functions. PSCX supposedly has something similar, but I’m obviously missing them completely.

  1. Get someone to provide a spreadsheet with all users that they want for their new install (or export from an existing AD using CSVDE)
  2. Fiddle with the file, remove any crap you don't want, add anything you might, and convert to a CSV. For a new install we tend to set the inital password to something based around the user's name (which you can automate creating with an Excel formula). My finished format is something like this: ``` givenname,middlename,surname,company,displayname,samaccountname,password ```
  3. Install Quest's ARM, and fire up the shell that it adds in your start menu
  4. Now it's simply a case of running the following, replacing my.domain/Path/To/OU/Users with your actual domain and the path to where you want the users placed (you can, obviously, make this part of the CSV, if you want) ``` import-csv C:\Path\To\Users.csv | foreach-object { New-QADUser -FirstName $_.givenname ` -LastName $_.surname ` -SamAccountName $_.samaccountname ` -ParentContainer my.domain/Path/To/OU/Users ` -displayname $_.displayname ` -name $_.displayname ` | ` Set-QADUser -UserPassword $_.password | Enable-QADUser } ```
  5. Grab yourself a cuppa, or a beer, and tell the boss that you've been slaving all night (optional, of course)

Just to add an SBS 2008 twist to it, if you create your users in this manner you’ll find that they show up in Active Directory Users and Computers, but not the SBS Console. The reason for this a special attribute on the object which doesn’t get set. There’s a nice article over at the SBS Blog which explains it for groups, but it’s also applicable for users.

What it doesn’t tell you is that for users, you can simply head into the SBS Console > Users, run the Change User Role for Accounts wizard, select Standard User, select your users (you’ll need to select the checkbox to show all users), and then let it do it’s magic. It’ll setup your users Exchange mailboxes and shared folders in a jiffy.