Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create a SQL server lab with the AutomatedLab PowerShell module
# Define the Lab, specify the virtualization engine and the path for the VMs to live
New-LabDefinition -Name SQLLab -DefaultVirtualizationEngine HyperV -VmPath C:\AutomatedLab-VMs\VMs
# Configure the Lab Network
Add-LabVirtualNetworkDefinition -Name SQLLab
Add-LabVirtualNetworkDefinition -Name 'Default Switch' -HyperVProperties @{ SwitchType = 'External'; AdapterName = 'Wi-Fi' }
$netAdapter = @()
$netAdapter += New-LabNetworkAdapterDefinition -VirtualSwitch SQLLab
$netAdapter += New-LabNetworkAdapterDefinition -VirtualSwitch 'Default Switch' -UseDhcp
# Map the SQL Server 2019 ISO to a friendly name
Add-LabIsoImageDefinition -Name SQLServer2019 -Path $labSources\ISOs\SQLServer2019-x64-ENU-Dev.iso
# Set up the defaults
# These will be used for all machines within your lab, unless you specifically overwrite them
$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:DomainName' = ''
'Add-LabMachineDefinition:Memory' = 1GB
'Add-LabMachineDefinition:OperatingSystem' = 'Windows Server 2019 Datacenter (Desktop Experience)'
# Create the domain controller
Add-LabMachineDefinition -Name DC1 -Roles RootDC -Network SQLLab
# Add a VM with the Routing role - this will allow internet connectivity in your lab
Add-LabMachineDefinition -Name Router1 -Roles Routing -NetworkAdapter $netAdapter
# Add a VM with the SQL Server 2019 role to create your SQL Server
Add-LabMachineDefinition -Name SQL1 -Roles SQLServer2019 -Network SQLLab
# Add a VM to use as the client machine
Add-LabMachineDefinition -Name Client1 -Network SQLLab
# Install the lab - this can take some time, especially if it's your first lab installation
# This will show the detailed summary of the installation and provide some tips on connecting
Show-LabDeploymentSummary -Detailed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment