I Locked the Joker Out of Every PC in Gotham

Gotham AD Masterclass, episode 2. Group Policy from zero, in a home lab.

There’s a USB stick on Dick Grayson’s desk. No name on it, just a paper tag: “Found this. Thought you’d like it.”

He plugs it in. Everyone does. There’s one file on it called prize, he double-clicks it, and it runs.

Mine was harmless. I wrote it, and all it does is print HA. HA. HA. But nothing on that PC stopped it. A real one wouldn’t announce itself. It would just run as Dick, with everything Dick can get to.

That’s where this episode of the Gotham AD Masterclass starts. If you’re new: I’m building a real company’s IT department in my home lab. The company is Wayne Enterprises, the domain is gotham.lab, and the Joker is an ex-contractor whose account was disabled on day one. He spends the series getting in anyway, the way real attackers do. This time it’s through a careless user and a PC with no rules.

By the end, every PC in Gotham blocks USB storage, shows a legal warning before sign-in, locks itself after 15 minutes, and wears the company wallpaper. It all comes from one place, and I never have to touch the PC again.

First, Gotham needed a PC

Up to now Gotham was one domain controller and 35 accounts. Nobody had a computer to sit at.

DHCP went on the domain controller. When I built the Gotham network in UniFi, I deliberately left DHCP off. A new PC needs three things: an address, a gateway, and to be told where DNS is. On a domain, DNS has to be the domain controller, or the PC can’t find it.

You could turn DHCP on in UniFi and point DNS at the DC. It works. But in a Windows shop, DHCP usually lives on a Windows server, it’s the version you’ll be asked about at work, and it can register every PC in DNS for you.

Install-WindowsFeature DHCP -IncludeManagementTools
Add-DhcpServerInDC -DnsName GOTHAM-DC01.gotham.lab -IPAddress 192.168.20.10
Add-DhcpServerv4Scope -Name "Gotham" -StartRange 192.168.20.100 -EndRange 192.168.20.200 -SubnetMask 255.255.255.0
Set-DhcpServerv4OptionValue -ScopeId 192.168.20.0 -Router 192.168.20.1 -DnsServer 192.168.20.10 -DnsDomain gotham.lab

The authorise step (Add-DhcpServerInDC) is the one people skip. A Windows DHCP server in a domain won’t hand out a single address until it’s authorised in Active Directory. That’s there to stop rogue DHCP servers.

The PC is WE-WS01, on Windows 11 Enterprise. I used the free 90-day evaluation. Pro joins a domain fine and most of this episode works on it, but one setting I push later, the forced lock-screen image, only works on Enterprise and Education. On Pro it silently does nothing. I’d rather show the real thing.

Joining was one line, run as the PC’s local admin:

Add-Computer -DomainName gotham.lab -NewName WE-WS01 -Credential GOTHAM\Administrator -Restart

(In a real company, use an account that can only join machines, not a Domain Admin. That’s a delegation lesson for later in the series.)

What Group Policy actually is

Think of it as a company handbook. You write the rules once, in one place, then decide which departments they apply to.

  • The handbook is a GPO, a Group Policy Object.
  • Pinning it to a department is a link. A GPO with no link does nothing.
  • Every GPO has two halves. Computer settings follow the machine. User settings follow the person.
  • Rules arrive at startup, at sign-in, and every 90 minutes or so after that (plus a random offset of up to 30). gpupdate /force gets them now.
  • When two GPOs disagree, they apply in the order Local, Site, Domain, OU, from the top of the tree down. The last one wins, so the GPO linked closest to the object wins.

The bit that catches everyone

I built WE-C-USB-Block (one setting: All Removable Storage classes: Deny all access), linked it to the Wayne Enterprises OU, ran gpupdate /force on Dick’s PC, and plugged the stick back in.

It opened straight away.

The tempting move is to start changing the GPO. Don’t. The setting was fine. The first question is always: is this GPO actually reaching this machine?

gpresult /r /scope computer   # run elevated, or the computer half comes back empty

Applied GPOs: Default Domain Policy, and nothing else. One line up was the reason: CN=WE-WS01,CN=Computers,DC=gotham,DC=lab.

The Computers folder isn’t an OU. It’s a container, and you can’t link a GPO to a container. Every PC you join lands there by default, so nothing you link to your company OU ever reaches it. It’s the same trap as the default Users folder from episode 1.

I moved WE-WS01 into a new Wayne Enterprises\Workstations OU, refreshed, re-plugged, and got access denied. Then one line so it never happens again:

redircmp "OU=Workstations,OU=Wayne Enterprises,DC=gotham,DC=lab"

New PCs now land somewhere policy can reach from their first boot.

When a GPO doesn’t apply, it’s nearly always one of four things:

  1. The object’s in the wrong place (OU)
  2. The setting’s in the wrong half (computer vs user)
  3. The PC can’t reach the DC, which is nearly always DNS
  4. It hasn’t refreshed yet

gpresult answers the first two in about ten seconds.

The mistake I made

This is the answer that got me my first IT job.

The interviewer asked whether I’d worked with Active Directory or Group Policy. I told him about the custom GPO I made in my first home lab that locked me out of my own domain. It took me 20 minutes to get back in, and I spent most of them looking in the wrong place. He laughed.

The point wasn’t that I’d broken something. It was that I had, and I knew what to look at the next time. These days, three habits stop it happening again:

  1. Every new GPO gets tested on one PC in a test OU first.
  2. If it goes wrong, untick Link Enabled. Don’t delete the GPO in a panic. The link turns off, the GPO’s still there, and you can switch it back on.
  3. Back up before you change anything.
Backup-GPO -All -Path C:\GPOBackups

The uniform

Two more GPOs, both linked to Wayne Enterprises and nowhere else:

GPOHalfWhat it doesWhy
WE-C-Workstation-BaselineComputerLogon banner title + textNobody can say they didn’t know the rules. Many companies are required to show one
Machine inactivity limit: 900 secondsSomeone always walks off to lunch unlocked
Forced lock-screen imageThe company look on every PC. Enterprise / Education only
WE-U-Desktop-BrandingUserDesktop wallpaper, FillFollows the person. JPG or BMP, not PNG

The images live in \\gotham.lab\NETLOGON\Branding, which every signed-in user can read and which copies itself to every domain controller. In production you’d copy them onto each PC first with Group Policy Preferences, so a laptop off the network still gets them.

Why three GPOs instead of one? Because when the wallpaper breaks, I want to switch off the wallpaper, and not USB blocking along with it. Small GPOs, one job each. And I switch off the empty half of each one (GPMC → Details → GPO Status), so the next admin can see at a glance what it’s for.

Same PC, different person

My favourite result in the episode: I signed in to WE-WS01 as Oswald Cobblepot, the catering contractor.

USB? Blocked. Wallpaper? Default Windows.

That’s not a bug. The USB block is a computer setting, and WE-WS01 lives in Wayne Enterprises. The wallpaper is a user setting, and Cobblepot lives in the Contractors OU, outside the company, on purpose.

Then I proved “closest wins”. I made a throwaway GPO linked at the domain root with a different banner title and ran gpresult /scope computer /h C:\Temp\ws01.html. The report has a Winning GPO column. The Wayne Enterprises GPO won. I set the domain link to Enforced, ran it again, and the domain GPO won. Enforced means the parent wins whatever’s underneath it. Use it rarely, and write down why.

Then I deleted it, because a GPO linked to the whole domain lands on the domain controller too. That’s exactly what I didn’t want.

Where Gotham stands

  • A DC that hands out addresses and tells every PC where to find it
  • Gotham’s first PC, joined, and in an OU policy can reach
  • Three small GPOs, linked to the company and nowhere else
  • A ten-second way to find out why a policy isn’t applying
  • A USB port the Joker can’t use

The Joker’s stick is dealt with. But there’s a folder in R&D called the Batcave, and right now it’s shared with every account in the domain, contractors included. That’s the next episode: groups and permissions.

📺 Watch the episode: https://youtu.be/YxFlAaUXgW8
🧰 Every command, plus New-GothamGPOs.ps1, which builds all three GPOs in one run: https://github.com/TrevTech-IT/gotham-ad-masterclass/tree/main/EP02-group-policy
⬅ Episode 1, the people: https://trevtech.blog/gotham-active-directory
🗂 The whole series: https://www.youtube.com/watch?v=0T5iN290njQ&list=PLfmRIg23g1uw&pp=sAgC

— Trev | I broke it. Fixed it.

Tags: home lab, active directory, group policy, GPO, Windows Server 2025, Windows 11 Enterprise, DHCP, Gotham AD Masterclass, enterprise IT

Leave a Comment

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

Scroll to Top