The AutomatedLab PowerShell module lets you deploy complex labs on Hyper-V and Azure with PowerShell. In this post, I'll show how you can quickly set up a home lab with AutomatedLab.
Latest posts by Anthony Howell (see all)

Getting started ^

To get started automating your home lab with the AutomatedLab PowerShell module, we first need to make sure we've got a couple of things up and running ahead of time.

  1. Hyper-V
    1. Windows 10: check out the 4sysops article on enabling Hyper-V
    2. Windows Server: Install Hyper-V using Server Manager
  2. The AutomatedLab PowerShell Module
Install-Module AutomatedLab -AllowClobber

Before you can deploy your first lab, you'll need to set up AutomatedLab so that it knows where to find the appropriate ISO files. To do this, you must first create what it refers to as the LabSources folder:

Create the lab sources folder

Create the lab sources folder

After the command finishes, it will output the location of the folder it creates. This is where AutomatedLab will look for installation files for operating systems and supported applications.

If you don't have any operating system ISO files, be sure to check out Microsoft's evaluation website . I grabbed the Windows Server 2019 ISO for this demo. Next, copy the ISO files of the operating system you want to deploy into the \ISOs folder inside of LabSources:

The folder with your ISO files

The folder with your ISO files

Now you'll want to make sure AutomatedLab recognizes them by running:

Get-LabAvailableOperatingSystem -Path C:\LabSources
Listing the operating systems in the Server 2019 ISO

Listing the operating systems in the Server 2019 ISO

Be sure to take note of the OperatingSystemName values; you're going to use these in your script for building your lab.

Building your first lab ^

Now that you have the AutomatedLab module installed and your operating system ISO files ready, we can build the first lab! To get started, open up your PowerShell script editor of choice. I prefer VS Code, but the Integrated Scripting Environment (ISE) will work fine if you don't want the hassle of installing another program.

In your script, you want to start by defining a Lab Definition—this is the metadata for your lab. As a very basic example, you only need to define a lab name and your virtualization engine, but you can get pretty fancy and set the path and limit resources for the entire lab if desired.

The easiest example to start with is:

New-LabDefinition -Name 'FirstLab' -DefaultVirtualizationEngine HyperV
Creating the lab definition

Creating the lab definition

You'll notice it did a couple of things:

  • Put the lab definition files in the default directory of C:\ProgramData\AutomatedLab\Labs
  • Ran an update on the SysInternals Suite tools since AutomatedLab uses those extensively
  • Rescanned the operating system files

Once you have the lab definition configured, you can start adding virtual machines (VMs) to your lab with the Add-LabMachineDefinition cmdlet.

It is important to note that by running this command you are not creating a VM; you are simply adding the data to the lab definition so that AutomatedLab will know what to create when you install the lab.

We can add a root domain controller; notice I'm using an operating system from before:

Add-LabMachineDefinition -Name DC01 -OperatingSystem 'Windows Server 2019 Datacenter Evaluation (Desktop Experience)' -Roles RootDC -DomainName ''

By specifying RootDC as the role for this server, it will automatically install the specified domain. Also, since I didn't select a network, it assigns one.

Adding a domain controller to the lab definition

Adding a domain controller to the lab definition

Then, if we want to add a member server with no role, we can run:

Add-LabMachineDefinition -Name Member01 -OperatingSystem 'Windows Server 2019 Datacenter Evaluation (Desktop Experience)' -IsDomainJoined -DomainName ''

This defines a member server in the specified domain:

Adding a member server to the lab definition

Adding a member server to the lab definition

Now that we've defined our two servers, we can have AutomatedLab deploy our lab by running:


If this is your first time running this command, and, like me, you chose not to specify a storage drive for your VMs in New-LabDefinition, AutomatedLab will run some tests to find the best storage drive.

After it completes its testing, it will also need to adjust some PowerShell remoting settings so it can talk to the VMs once they start up. If you are running your lab on a work computer, chances are you won't be able to adjust many of the settings, but for a home system or a dedicated lab server, these are fine.

Now this will take some time to run because it will be creating the VMs and setting up Active Directory with any other roles that you defined.

After it finishes, assuming you have the Hyper-V Manager installed, you can launch that and admire your easily built VMs!

If you didn't specify a password, the default is: Somepass1.

The final product, up and running

The final product, up and running

Next, you can have AutomatedLab clean everything up by running:


Looking forward ^

If you save your script as a .ps1 file, any time you need to rebuild that lab, all you need to do is to run the script, wait the 10 to 15 minutes, and you'll have a lab ready to go!

If you'd like to see some of the advanced features of AutomatedLab, be sure to check out their Github repository.