PowerShell to quickly provision an Active Directory for events and demonstrations

Just now I’ve uploaded my first script into the Microsoft TechNet Script Repository… New-DemoAD.ps1

This is a PowerShell script/function one can use to quickly fill an Active Directory with demo users and groups, ideal for events and demonstrations.

For example, an event “TechEvent” has 200 visitors which each require an account in a fictional company. This company has 3 departments: IT, Sales and Finance.

This script will create 200 users (TechEvent001 to TechEvent200), fill the “Department” user property with a random department (chosen from the given departments), create Global Groups named after the departments and create Domain Local Groups (which can be used to configure access to resources) for each department.
Next, users will be added to the appropriate department (Global) group and each department group will be added to the appropriate (domain local) group.