How shine0078/home-lab works
1. This repository is an end-to-end, scripted Active Directory home lab. The core system is a Hyper-V host running one Windows Server 2022 domain controller (DC01) and two Windows 11 client VMs, all tied together on an internal virtual switch.
2. The architecture is split into setup layers:
- hyperv/ provisions the virtual machines and network.
- scripts/ configures the Windows/AD services after the OS is installed.
- dsc/ provides a declarative alternative using Desired State Configuration.
- modules/ADHomeLab holds reusable PowerShell functions shared by the operational scripts.
3. The infrastructure boundary starts on the Hyper-V host. Provision-All.ps1 creates the lab VMs and internal switch, then unattend XML files automate the initial OS install for Server 2022 and Windows 11. This is the bootstrap layer before any AD-specific configuration happens.
4. DC01 is the control plane for the lab. It hosts Active Directory Domain Services, DNS, DHCP, Group Policy, and Windows Event Forwarding collection. Most other automation ultimately targets this machine because it owns identity, policy, and central logging.
5. The client boundary is the two Windows 11 machines. They are domain-joined endpoints used to validate policy, security controls, and operational scenarios. Their main data flow is outbound telemetry and event forwarding back to DC01.
6. The configuration workflow is intentionally staged:
- 01-Setup-DC.ps1 establishes the domain controller.
- 02-Join-Domain.ps1 joins clients to the domain.
- 03-Configure-GPOs.ps1 applies baseline and advanced Group Policy.
- 04-Create-Users.ps1 loads users from data/users.csv.
- 05-Validate-Lab.ps1 checks the environment.
- Additional scripts handle hardening, monitoring, backup, restore, and RBAC.
7. Policy and identity data are mostly file-driven. data/users.csv feeds bulk user creation, data/monitored-events.csv defines monitored security/event patterns, and config/gpo-exports/ is reserved for exported GPO artifacts. This makes the lab reproducible and keeps configuration outside the scripts themselves.
8. Security and governance are a major subsystem rather than an add-on. The scripts and docs implement STIG/CIS-inspired hardening, password and firewall policy, ASR rules, audit settings, NTLM/SMB protections, and RBAC delegation. The docs/security-baseline.md and docs/rbac-matrix.md files describe these controls at a design level.
9. Monitoring and operations center on Windows Event Forwarding plus scheduled-task-based alerting. scripts/07-Setup-Monitoring.ps1 configures collection/forwarding, while the docs/security-dashboard.md and the runbooks document how alerts are interpreted and responded to. This creates a clear flow from clients to the domain controller’s logging/monitoring role.
10. Backup and recovery are separate operational paths. scripts/08-Backup-Lab.ps1 and scripts/09-Restore-Lab.ps1 support disaster recovery, with docs/backup-strategy.md defining the intended RPO/RTO and recovery process. The runbooks tie specific failure modes to restore actions.
11. The repository also includes a test and CI boundary. tests/ contains Pester-based validation and syntax checks, while .github/workflows/lint.yml runs PowerShell linting and tests in GitHub Actions. This enforces script quality without changing the lab topology itself.
12. vagrant/ is an alternate provisioning path, but it still targets the same underlying lab model: a domain controller plus clients on Hyper-V. In diagram terms, it is an optional entry point to the same environment rather than a separate runtime system.
Main entry points: 06-Harden-Baseline.ps1 Ops security · Provision-All.ps1 Provision All · ADHomeLab.psm1 ADHomeLab module · 04-Create-Users.ps1 Create users
Components 22
Bootstrap
Hyper-V provisioning and first-boot installation layer
- Hyper-V host · Physical or local host that creates and runs the lab
- Internal switch · Isolated virtual network for the lab
hyperv/01-Create-Switch.ps1 - Provision All · Creates the lab VMs and wires up the virtual network
hyperv/Provision-All.ps1 - Unattend images · Answer files that automate first boot for Server 2022 and Windows 11
hyperv/unattend/unattend_Server2022.xml - Vagrant entry · Optional provisioning path that targets the same lab model
vagrant/bootstrap-dc.ps1
Lab runtime
The Active Directory domain controller and client VMs
- DC01 · Windows Server 2022 domain controller and lab control plane
- Win11 clients · Two domain-joined Windows 11 client VMs
Operations
Staged PowerShell automation and shared module
- ADHomeLab module · Reusable PowerShell functions used by operational scripts
modules/ADHomeLab/ADHomeLab.psm1 - Setup DC · Creates and configures the Active Directory foundation
scripts/01-Setup-DC.ps1 - Join domain · Joins client VMs to the domain
scripts/02-Join-Domain.ps1 - Configure GPOs · Applies baseline Group Policy and security settings
scripts/03-Configure-GPOs.ps1 - Create users · Bulk user creation from CSV data
scripts/04-Create-Users.ps1 - Ops security · Hardening, monitoring, backup, restore, and RBAC automation
scripts/06-Harden-Baseline.ps1 - Validate lab · Checks the environment after provisioning and configuration
scripts/05-Validate-Lab.ps1
Data and docs
File-driven inputs and design/runbook references
- Users CSV · Source data for bulk account creation
data/users.csv - Events CSV · Monitored event patterns used by monitoring automation
data/monitored-events.csv - Security docs · Baseline hardening and RBAC design references
docs/security-baseline.md - Backup docs · Backup and restore strategy plus failure runbooks
docs/backup-strategy.md - Dashboard docs · Security dashboard and operational interpretation guidance
docs/security-dashboard.md
Quality and alternate paths
Validation, CI, DSC, and Vagrant entry points
- DSC config · Desired State Configuration path for the same lab outcome
dsc/LabDscConfiguration.ps1 - Tests · Syntax and behavioral checks for key scripts
tests/Project.Tests.ps1 - CI workflow · Runs linting and tests in GitHub Actions
.github/workflows/lint.yml
Connections 27
- Hyper-V host → Provision All: runs · Host executes the bootstrap script
- Provision All → Internal switch: creates · Bootstrap provisions the isolated network
- Provision All → Unattend images: uses · First boot is automated by answer files
- Provision All → DC01: creates · Defines the domain controller VM
- Provision All → Win11 clients: creates · Defines the client VMs
- Vagrant entry → Provision All: same model · Alternative entry point to the same lab topology
- DC01 → Win11 clients: serves · Domain, DNS, DHCP, GPO, and forwarding services support endpoints
- Setup DC → DC01: configures · Initializes the domain controller
- Join domain → Win11 clients: joins · Enrolls the clients into the domain
- Configure GPOs → DC01: applies · Stores and applies Group Policy on the controller
- Create users → Users CSV: reads · Identity data drives account creation
- Create users → DC01: writes · Creates directory objects on the domain controller
- Ops security → DC01: hardens · Security, monitoring, backup, restore, and RBAC target the controller
- Ops security → Win11 clients: hardens · Endpoint policy and control-plane settings affect clients too
- Ops security → Events CSV: uses · Monitoring definitions are file-driven
- Validate lab → DC01: checks · Validates core domain services and configuration
- Validate lab → Win11 clients: checks · Confirms endpoint state and domain join health
- ADHomeLab module → Setup DC: supports · Shared helper functions reduce duplication
- ADHomeLab module → Configure GPOs: supports · Reusable helpers back policy automation
- ADHomeLab module → Ops security: supports · Shared PowerShell logic also powers ops workflows
- Security docs → Ops security: describes · Baseline hardening and RBAC design are documented here
- Backup docs → Ops security: describes · Recovery strategy and runbooks guide restore actions
- Dashboard docs → Ops security: guides · Monitoring interpretation and alerting workflow
- DSC config → DC01: configures · Declarative alternative for the same lab environment
- Tests → Configure GPOs: covers · Pester validates policy script behavior
- Tests → Create users: covers · Tests cover user creation and parsing paths
- CI workflow → Tests: runs · GitHub Actions executes validation and linting