Yes, I like my scripts with a verbose output.
See Demos
This is a powershell script to quickly setup an AD environment. With random user names and descriptions. The structure of the AD is defined in model.json, see below for possible customization. You have to run this script twice if you want to install ADDS and populate the AD with dummy content.
During my sysadmin formation I wanted to have a script to populate an Active Directory with dummy content.
The content generated comes from the model.json (structure of the AD), and the names.csv (user names).
- It follows some best practices (GGS, DLGS, Share rights), and some design I find clean (everything what's not
Microsoft BuiltInin a_ROOTOU) - What this script will do:
- Install ADDS roles if not already installed
- Generate OUs (following model.json)
- Generate one OU per Department
- Generate 5 security groups (3 GGS et 2 DLGS) per Department
- Create one share per Department (managers have RW while users have only RO)
- Generate one manager per Department (random from names.csv)
- Generate X users per Department (random from names.csv, X defined in model.json)
- On a windows server as administrator (tested on DataCenter2022)
Set-ExecutionPolicy -ExecutionPolicy Unrestricted- Well, this is a lab and I wont pay for a code signing cert.Unblock-File -Path .\Set-DummyAD.ps1- I still dont have 500$ to spend on this script.- Download & extract the latest release
.zipfile - cd into the downloaded folder
- Review
model.json .\set-DummyAD.ps1
- All the users will have
Test1234=as their password. (customizable in model.json) - If ADDS role is installed with this script the DSRM password is also
Test1234=(uses the same password in model.json) - This script is not for a production environment but a for a quick setup of an AD lab.
- CSV file name should be
names.csv - CSV headers should be
firstName;lastName - The CSV delimiter should be
;, verify with notepad if necessary. - Make sure there is no duplicates, nor weird characters (I do not sanitize those names)
- Make sure there is enough data to populate the AD ((1 + $UsersPerDept) * $nbrOfDepts should be greater than $nbrOfUsersInCSV)
Do not rename the file
| Key | Expected values | Comments |
|---|---|---|
| PSW | string |
Should be compliant with AD password policy |
| PreventOUDeletion | 0 or 1 to disable or enable it |
0 = You can delete the OUs |
| RootOUName | string |
|
| CustomOUs | array of string |
See Customize the OUs |
| RootShareName | string |
The name the directory that all the shared folder will be |
| RootSharePath | string |
The \\ is normal in a json file, should be consistent with RootShareName |
| Depts | dictionary |
Key:value pairs of DeptFullName:DeptShortName |
| AdditionalDesc | array of string |
|
| UsersPerDept | integer |
Number of users per department |
You can customize the OUs but:
- My script can't go deeper (:sadge:) than 2 levels
- eg: "Computers/Servers" => OK
- eg: "Computers/Server/001" => NOK
- Make sure you define the parent OU BEFORE the child OU in the list. Or the child OU generation will throw an error because the parent doesn't exist.
- Please don't remove the
Groupsentries, as I use them to generate the security groups - Please don't remove the
Usersentry, as I use it to generate the users under it.

