- Install K3s, a lightweight, production-grade Kubernetes distro - Mon, Mar 20 2023
- VMware NSX Advanced Load Balancer: Installation and configuration - Fri, Mar 10 2023
- NetCrunch 13: Real-time network monitoring, traffic analysis, alerts, and performance reporting - Tue, Mar 7 2023
AutomatedLab is a self-contained solution that provides the tools needed to provision a lab environment in an automated way. AutomatedLab allows:
- Setting up a lab and test environments
- Using Hyper-V or Azure with multiple solutions (VMware isn't listed in the documentation, but you can use nested virtualization with a Hyper-V server running on vSphere)
- Provisioning a single VM very quickly
The main advantages of AutomatedLab are its simplicity and easy commands. For example, creating a single machine consists of three lines:
New-LabDefinition -Name Win10 -DefaultVirtualizationEngine HyperV Add-LabMachineDefinition -Name Client1 -Memory 1GB -OperatingSystem 'Windows 10 Pro' Install-Lab
The installation of AutomatedLab is straightforward. You can pull the modules from the PowerShell gallery or install the solution using a downloaded MSI file. Below, I will show how PowerShell works. The commands documented by AutomatedLab are shown below.
It's not well documented, but I received an error installing AutomatedLabs without it. This installs Pester 5.x vs. the 3.x installed by default:
Install-Module Pester -Force Install-PackageProvider Nuget -Force
Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider Install-Module AutomatedLab -AllowClobber
Creating the Lab Sources folder
Now that we have the AutomatedLab PowerShell module installed, we can create the Lab Sources folder as the working directory of AutomatedLab. This is where resources such as ISOs, VHDs, scripts, and other items are stored.
The cmdlet to create the Lab Sources folder is as follows:
It defaults to the root of your CDRIVE. However, this can be modified using the "-Drive" parameter.
The AutomatedLab cmdlet goes to GitHub and pulls down the .zip file containing the framework of the LabSources folder and extracts it to the defined location. Below is a screenshot of the LabSources folder after the cmdlet finishes.
Next, as part of creating the LabSources folder, we need to copy an ISO file into the LabSources > ISOs directory. Below, I have copied a Windows Server 2019 ISO. The ISO file is used when creating your Lab Machine definition file, which we will do below.
Another resource provided out of the box is the SampleScripts folder, which has scripts for deploying into different types of environments.
Create a new lab definition
The lab definition defines the specifications of the lab to be provisioned by AutomatedLab. The syntax for creating the new lab definition is as follows:
New-LabDefinition -Name <your lab definition name> -DefaultVirtualizationEngine <engine>
In the example below, I use Hyper-V as the default virtualization engine.
At this point, you can also list the available operating systems in your Lab Sources folder. To do that, use the following cmdlet:
As you can see below, it correctly reads the ISO file in the LabSources > ISO directory and lists out the available Windows Server 2019 editions.
Create a lab machine definition
The lab machine definition defines the machine name and the operating system that will be installed for the virtual machine. This is set using the following cmdlet:
Add-LabMachineDefinition -Name <virtual machine name> -OperatingSystem <Your operating system>
One of the nice features of the AutomatedLab configuration is that the module automatically takes care of the networking side. As you can see below, it creates a new Hyper-V virtual switch and assigns an address space to the environment. The resulting virtual machine(s) will be connected to the new network when the lab is installed.
Installing the lab environment
Since we have created the lab definition and the lab machine definition, we are ready to deploy a Windows Server in a VM with AutomatedLab. In this simple demo, the lab installation will create a single instance of Windows Server 2019. To install the lab, run the following cmdlet:
The Install-Lab cmdlet will ask several security-related questions regarding configuration settings. The configuration settings are required to allow your lab host to interact easily with the resulting lab VMs in the environment. While these are settings you most likely will not want to enable in production, they are mostly OK for a lab environment. They include:
- Are you OK with enabling WinRM and CredSSP?
- Are you OK with putting '*' into the TrustedHosts to allow the host to connect to any possible lab VM?
- Are you fine with setting the AllEncryptionOracle to 2?
If you open an Explorer window and browse to the AutomatedLab-VMs folder, you will see the base image VHD image. Its purpose is to have much quicker subsequent deployments. Therefore, after the base image is created, it simply uses it for future deployments, which take only a minute or two instead of the entire time it takes for the base image.
After creating the base image, AutomatedLab creates the actual lab VMs. It waits for these to start, checks WinRM connectivity to verify, and completes afterwards.
After the build completes, if you want to see a summary of the build process for the lab, you can run the following cmdlet:
It shows how long it took to build the lab, the lab name, and other summary information. You can open up your Hyper-V Manager and connect to the virtual machine. You can also have AutomatedLab connect via RDP using the following cmdlet:
Connect-LabVM -Computername <your lab computername>
Wrapping up and impressions
Deploying a Windows Server in a VM with AutomatedLab is extremely easy. The solution takes the heavy lifting from automating the provisioning of a lab environment that may include Windows Servers, clients, and other solutions such as SQL, Exchange, Active Directory, and others.
Subscribe to 4sysops newsletter!
Combined with the example scripts and scripts from the community built for AutomatedLab, it is a solid, well-documented, and supported tool for automated lab deployments.
Want to write for 4sysops? We are looking for new authors.
I’m not one to leave comments but this looks awesome. I messed around with the hydration pack in it’s early start but it was just a lot of configuration. This looks like it’s easy and straight to the point!.