πŸ§ͺ Deploy Complete Labs with AutomatedLab and PowerShell – A Step-by-Step Guide

πŸ” 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:

RequirementMinimum
OSWindows 10/11 Pro or Enterprise
HypervisorHyper-V enabled
RAM8 GB minimum (16 GB+ preferred)
Disk Space50+ GB free
Admin PrivilegesRequired

πŸ”Œ 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:

  1. Downloads ISOs (if not present in cache)
  2. Creates and configures VMs
  3. Installs specified roles and features
  4. 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


🎯 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.

More From Author

IT-Tools: an essential web toolkit for IT pros

Maester: Automate Your Microsoft 365 Security Tests with Confidence

Leave a Reply

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