π Introduction
Lab environments are essential for testing, training, and simulating enterprise-grade IT infrastructure. However, manually deploying virtual machines (VMs), configuring services, and setting up networks is not only tedious but also prone to human error.
AutomatedLab, an open-source PowerShell module, streamlines the entire process by automating the deployment of full-featured lab environments in minutes. This guide walks you through setting up a fully automated lab from scratch, complete with domain controllers, servers, and client machines using PowerShell.
π οΈ What is AutomatedLab?
AutomatedLab (AL) is a PowerShell-driven framework designed to automate the setup of test environments. It supports deployments on Hyper-V, Azure, and VMware, and is capable of provisioning VMs with different roles, such as:
- Active Directory Domain Controllers
- DNS, DHCP, IIS, SQL, Exchange
- Windows Server & Client machines
- Custom network topologies
β Benefits of Using AutomatedLab
- Consistency: Every lab is deployed identically, eliminating configuration drift.
- Speed: Full environments can be built in minutes.
- Scripting-friendly: Reusable, modular, and fully scriptable with PowerShell.
- Scalable: Create single-node labs or multi-tier enterprise environments.
- Free & Open-source: No licensing cost.
π¦ Prerequisites
Before deploying labs, ensure the following requirements are met:
π§° System Requirements:
Requirement | Minimum |
---|---|
OS | Windows 10/11 Pro or Enterprise |
Hypervisor | Hyper-V enabled |
RAM | 8 GB minimum (16 GB+ preferred) |
Disk Space | 50+ GB free |
Admin Privileges | Required |
π Enable Hyper-V (if not already enabled)
powershellCopierModifierEnable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
π Reboot after enabling Hyper-V.
π₯ Step 1: Install AutomatedLab
Install the module from the PowerShell Gallery:
powershellCopierModifierInstall-Module -Name AutomatedLab -Scope CurrentUser -Force -AllowClobber
Also install required dependencies:
powershellCopierModifierInstall-Lab -Scope CurrentUser
β οΈ You may be prompted to trust the repository. Answer
Yes
.
π§± Step 2: Set Up a Basic Two-Node Lab
Create a file called TwoNodeLab.ps1
and add the following script:
powershellCopierModifierNew-LabDefinition -Name TwoNodeLab -DefaultVirtualizationEngine HyperV
Add-LabMachineDefinition -Name DC1 -Roles RootDC `
-Memory 2GB `
-OperatingSystem 'Windows Server 2022 Standard Evaluation (Desktop Experience)'
Add-LabMachineDefinition -Name Client1 `
-OperatingSystem 'Windows 11 Pro' `
-Memory 2GB `
-DomainName contoso.com
Install-Lab
This will:
- Create a virtual switch
- Deploy 2 VMs (DC1 and Client1)
- Install the Active Directory role on DC1
- Join Client1 to the
contoso.com
domain
β³ Step 3: Monitor and Access the Lab
Once deployment starts, AutomatedLab performs these steps automatically:
- Downloads ISOs (if not present in cache)
- Creates and configures VMs
- Installs specified roles and features
- Applies networking, IP settings, and domain join
Deployment typically takes 10β30 minutes depending on system performance.
To verify:
powershellCopierModifierShow-LabDeploymentSummary
To interact with a VM:
powershellCopierModifierEnter-LabPSSession -ComputerName DC1
Or use Hyper-V Manager’s Connect option.
π§ͺ Advanced Scenario: Three-Tier Application Lab
Create a multi-tier lab with a domain controller, a SQL Server, and a web application server:
powershellCopierModifierNew-LabDefinition -Name ThreeTierLab -DefaultVirtualizationEngine HyperV
Add-LabMachineDefinition -Name DC1 -Roles RootDC `
-Memory 2GB `
-OperatingSystem 'Windows Server 2022 Standard Evaluation (Desktop Experience)'
Add-LabMachineDefinition -Name SQL1 -Roles SQLServer2019 `
-Memory 4GB `
-DomainName corp.local `
-OperatingSystem 'Windows Server 2022 Standard Evaluation (Desktop Experience)'
Add-LabMachineDefinition -Name Web1 -Roles WebServer `
-Memory 2GB `
-DomainName corp.local `
-OperatingSystem 'Windows Server 2022 Standard Evaluation (Desktop Experience)'
Install-Lab
This script sets up a domain, installs SQL Server 2019 on SQL1, and IIS on Web1.
π Managing the Lab
List all running lab VMs:
powershellCopierModifierGet-LabVM
Remove a lab:
powershellCopierModifierRemove-Lab -Name ThreeTierLab -Confirm:$false
Export a lab config:
powershellCopierModifierExport-Lab -ExportPath "C:\LabExports\ThreeTierLab.xml"
Reimport a lab later:
powershellCopierModifierImport-Lab -Path "C:\LabExports\ThreeTierLab.xml"
Install-Lab
π§° Customize Further with PowerShell DSC or Scripts
You can extend AutomatedLab further by adding your own PowerShell scripts:
powershellCopierModifierAdd-LabMachineDefinition -Name WebApp `
-Scripts @("C:\Scripts\InstallMyApp.ps1") `
-OperatingSystem 'Windows Server 2019 Standard Evaluation'
This allows complete automation of custom apps, GPOs, registry tweaks, etc.
π§ Use Cases
- Certification Prep: Build a lab for Microsoft Azure, MCSA, or Security+.
- Dev/Test: Safely test configurations, updates, and software.
- Training Environments: Set up classroom labs quickly.
- Proof of Concepts (PoCs): Deploy realistic IT infrastructures for demos.
π Resources & Further Reading
- π AutomatedLab Documentation
- π GitHub Repository
- π PowerShell Gallery β AutomatedLab
- π₯ YouTube Demos
- πPowershellLabTemplate
π― Conclusion
AutomatedLab + PowerShell transforms how IT professionals build, test, and experiment with complex infrastructures. What once took hours or even days now takes minutes. With reusable scripts and powerful automation, you can spin up complete environments with the click of a buttonβand tear them down just as easily.