I Built Gotham City’s Active Directory

Gotham AD Masterclass — Episode 1 https://youtu.be/oZ2VPQmvuPA

Most Active Directory labs are full of accounts called user1, user2 and testuser3. You build it, you click through the wizards, and a week later you couldn’t tell anyone a single thing about it, because there’s nothing in it worth remembering.

So I rebuilt mine as a real company: Wayne Enterprises.

Bruce Wayne runs it. Lucius Fox runs the tech. Jim Gordon runs the helpdesk. Alfred is the service account that never sleeps. And Jack Napier, username joker, is a terminated contractor whose account was disabled on day one. He spends the rest of the series trying to get back in.

This is episode 1 of the Gotham AD Masterclass: real Active Directory, run the way a company actually runs it, one episode at a time. (The domain controller itself was built in Episode 0, on Windows Server 2025.)

Why theme a lab at all

The question that got me my first IT job was “Have you worked with Active Directory or Group Policy?” I had, in my lab, and I answered with the story of locking myself out of my own domain. That’s what a lab is for. Not the clicking, the stories.

A themed domain gives you stories by default:

  • You remember the structure. “Where does Dick Grayson sit?” has an answer. “Where does testuser4 sit?” is a question nobody has ever asked.
  • Security needs a villain. A lockout policy is an abstract setting until someone’s trying to get past it.
  • Interviews run on specifics. “I built Wayne Enterprises’ IT department, kept ex-staff outside the policy scope, and put contractors on expiry dates” sounds like someone who’s done the job.

Before you start

This episode starts from an empty, healthy domain: GOTHAM-DC01, Windows Server 2025, gotham.lab, built in the prequel. If you haven’t got one yet, start with Episode 0: I Built Gotham City’s Domain Controller. It covers the Proxmox VM, patching before promotion, the 2025 functional level, and a DNS mistake worth breaking on purpose once.

Github Repo: https://github.com/TrevTech-IT/gotham-ad-masterclass

If you haven’t got a hypervisor at all, my Build Your First Home Lab ebook covers the stack underneath: Newsletter

Step 1: The org chart

gotham.lab
├── Wayne Enterprises
│   ├── Executive · R&D · Applied Sciences · Security · IT · Operations
├── Former Employees     ← disabled ex-staff
├── Contractors          ← expiry dates (and the Joker, disabled)
└── Service Accounts     ← svc-alfred, svc-oracle

Two decisions do the heavy lifting:

  1. Nothing lives in the default Users folder. It’s a container, not an OU, and you can’t link a Group Policy to a container.
  2. Ex-staff and contractors sit beside Wayne Enterprises, not inside it. Every policy and helpdesk permission in this series targets Wayne Enterprises. Leavers inside it would inherit all of it. Later, Gordon’s helpdesk can reset Dick’s password but can’t re-enable the Riddler, and that’s purely down to where the OUs sit.

Disabled, not deleted: the Joker’s account stays so its history is still there when someone starts asking questions.

Step 2: Hire all of Gotham in one script

Thirty-five accounts, every one filled in: title, department, company, office, phone, employee ID, email, and manager, so Dick → Kirk Langstrom → Lucius → Bruce shows up properly on the Organization tab. Contractors and interns get expiry dates. Former staff arrive disabled. Service accounts get never-expiring passwords (and yes, the production answer is a gMSA).

# Dry run first. Every account it WOULD create, nothing touched.
.\New-GothamUsers.ps1 -WhatIf

# Looks right? Open the doors.
.\New-GothamUsers.ps1

Result: 10 OUs (the script builds 9, because I made Wayne Enterprises by hand to show how), 35 accounts, 28 manager links.

Two details I like:

  • Naming collisions: Lucius Fox is lfox. His son Luke is also lfox, so he’s lfox2. Pick your collision rule before you need it.
  • The Joker picked his own username. Every other account follows the naming standard. His doesn’t. In a real audit, that’s your first red flag.

The six admin accounts (bwayne-adm and friends) are in the roster but held back behind a -IncludeAdminTier switch. That’s its own episode.

The scripts and full roster are free on GitHub: [GITHUB LINK: TrevTech-IT/PowershellForActiveDirectory]

Step 3: Joiners, movers, leavers

You build a domain once. People join, move and leave every week, and the leavers are where it goes wrong. Imagine someone left eighteen months ago and can still open the payroll folder.

Joiner: HR adds one row to the CSV (Carrie Kelley, R&D intern, 120-day expiry) and the same script runs again. One account created, 35 skipped. It never touches anyone who already exists.

Mover: Dick Grayson gets promoted.

Set-ADUser -Identity dgrayson -Title "Lead Systems Engineer" -Manager lfox

Re-running the users script won’t drag him back under his old manager. It only sets managers on accounts it has just created.

Leaver: Tim Drake resigns. Disabling the account isn’t enough, because that leaves him in every group, on the org chart, and sitting next to current staff. So the offboarding script does the whole job:

.\Invoke-GothamLeaver.ps1 -Identity tdrake -Reason "Resigned" -WhatIf
.\Invoke-GothamLeaver.ps1 -Identity tdrake -Reason "Resigned"

It disables him, strips his groups, clears his manager, stamps the description (Left <date> - Resigned. Was: Graduate Engineer, R&D.) and moves him to Former Employees. It refuses to touch anyone with admin rights, nested or direct. Offboarding an admin is a job you do on purpose.

Step 4: Keep the Joker out

Out of the box, the domain lockout threshold is 0, which means never. You can guess a password forever.

# Before: LockoutThreshold 0, MinPasswordLength 7
Get-ADDefaultDomainPasswordPolicy

# Three strikes, 15 minutes, 14-character minimum
Set-ADDefaultDomainPasswordPolicy -Identity gotham.lab `
    -LockoutThreshold 3 -LockoutDuration 00:15:00 `
    -LockoutObservationWindow 00:15:00 -MinPasswordLength 14

I use three so the demo’s quick. CIS says five or fewer. Then the Joker goes for Bruce: three wrong passwords, and bwayne is locked. Even the right password bounces.

Search-ADAccount -LockedOut | Select-Object Name, SamAccountName
Unlock-ADAccount -Identity bwayne

And here’s the twist: the Joker never got in, but he locked the CEO out of his own company without knowing a single password. Lockout protects passwords and hands attackers a lever, which is why the duration is fifteen minutes and not forever.

One more honest caveat: lockout stops someone hammering one account. It does not stop password spraying (one common password tried once against every account). That never trips the threshold. Logs catch it, and we’ll get there.

The gotchas

  • Test that the password policy sticks. Set-ADDefaultDomainPasswordPolicy writes through the Default Domain Policy, but some values can be overwritten on the next policy refresh. Run gpupdate /force and check again.
  • Leavers stay out of groups. The groups script skips disabled accounts, so an out-of-date CSV can’t quietly put a leaver back in.
  • Time drift breaks Kerberos. More than five minutes between a machine and the DC and logins start failing with errors that never mention time.

And Bruce?

Run Get-ADGroupMember "Domain Admins" and there’s one member: the built-in Administrator. Not Bruce. He owns the company, but he doesn’t get the keys to the domain on the account he reads his email with. Why is a whole episode.

What’s next in Gotham

Right now nothing stops Dick Grayson plugging in whatever USB stick turns up on his desk, and the Joker’s already left one there. Group Policy is how you stop that. It’s the next build.

Watch the full episode on the channel, every step in this post, on screen, in order. Start with Episode 0 if you’re building along. And if you build your own themed domain, tell me the cast.

Tags: homelab, active directory, windows server 2025, proxmox, powershell, enterprise IT, gotham ad masterclass

— Trev | I broke it. Fixed it.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top