Mass importing users with Powershell

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.

SBS 2008 Shared & RedirectedFolders paths

By default Windows SBS 2008 has 2 shares setup - RedirectedFolders and UserShares, along with the various bits and bobs in the group policy to get it to work. Sadly they've placed the actual directories in the root of C:\. I don't like that. I'm fussy about file placement and it would be nice to move it to where we usually have the files (and have done since SBS 2000); D:\Data\..., which brings things into line with our standard setup that we tend to use at work.

Now you can just simply de-share the original directories, and move them to whereever you want. However this has the downside of causing issues (recreating the folders) if you create user accounts with the SBS 2008 console (since it also creates the various redirected folders for the user, and I know that several of our customers will be using this console).

Luckily there is provision to move these folders to another location. If you use the console you'll see that you can simply move it from drive to drive. However, if you delve into the registry you can see that 2 magic keys get created, which if you manually alter allows you to effectively place the directories where ever you like.

If you browse to
HLKM\SOFTWARE\Microsoft\SmallBusinessServer\Storage
You'll find that the following entries will either exist, or need to be created -
SharedRootPath SharedRootName FRRootPath FRShareName

*RootPath specifies the location for the user shared and redirected folders, where as the *ShareName specify the actual name of the shares themselves. Handy.

VPS.net

Being the good little customer that I am, I tend to try and keep an eye on what upstream are doing. To that end I've been keeping an eye on VPS.net; UK2.net's newest business venture. I'm one of the lucky 80 or so that have gotten into the beta, and I've got to say, I'm really impressed with what the guys have put together so far.

Basically what they're providing is a fault tolerant, brilliantly easy to use virtual server infrastructure, based on Linux and Xen. Unlike most other (more traditional) VPS providers you simply don't buy a VPS and then manage it, you actually buy "nodes" or "slices" (they're actually refered to as both terms in the web interface at present), which you then assign to various virtual servers in any fashion you want, with the ability to reassign at a later date should things change.

There are a few cool things about the whole setup:

  1. It's delightfully quick
  2. It's absolutely fanastically easy to use
  3. You can get console access direct through the web interface, along with all the other bits and bobs that you may need
  4. You have the option for live backups and restores - very nice, very quick considering its all LVM, and makes reverting any stupid changes very easy (such as rm -rf'ing your root partition)

I'd love to see how things fare as the product launches, and it gets busier, but so far I'd be pretty happy to convert my physical server to a virtual VPS.net instance, should the circumstances arise.

Party like it's 1234567890!

coolepochcountdown.com says it all really. I think I might party myself silly and persuade my non-geeky housemates to partake.

What will you be doing?