/WSLab

Windows Server rapid lab deployment scripts

Primary LanguagePowerShellMIT LicenseMIT

WSLab in MVPDays

WSLab in CDCGernabt

Project Description

  • Deployment Automation of Windows Server labs on WS2016/Windows10 Hyper-V

  • Simply deploy your lab just with these scripts and ISO file.

  • Lab can run LAB on Windows 10, Windows Server 2016 (both Core and GUI) or even in Azure VM

  • Major differentiator is that once hydrated (first 2 scripts), deploy takes ~5 minutes. Cleanup is ~10s.

  • Options for setting up a Windows Server 2016-based lab are simpler than other available lab automation systems as the project is based on Powershell scripts rather than XML or DSC configuration files.

  • Scripts are not intentionally doing everything. You can spend nice time studying scenarios.

  • This solution is used in Microsoft Premier Workshop for Software Defined Storage, Hyper-V and System Center VMM. If you have Premier Contract, contact your TAM and our trainers can deliver this workshop for you.

  • Follow #wslab hash tag to get latest news.

  • Check this page for end to end scenarios!

Videos

Note: Some videos may be a bit outdated as there is continuous innovation going on in the scripts.

HowTo

Step 1 Download required files (prerequisites)

Scripts

Windows Server 2016

or Windows Server 2019

or Windows Server Insider Preview

NOTE: There is no LTSC available yet. In 17744 was a bug, so during deployment process DC creation takes forewer. Workaround is to just log in as corp\Administrator to DC and it magically finishes.

Optionally you can download SCVMM 2019 files

Note: watch entire process how to deploy SCVMM here (bit outdated)

Tip: You can download CU and UR using DownloadLatestCU script

You will find this script in CreateParentDisks folder

Step 2 Create folder and Unzip scripts there

Step 3 (Optional) Check the LabConfig.ps1

  • Edit LabConfig.ps1 to specify the lab setup that you require (such as different domain name, Domain Admin name...). This script file documents the available configuration options. (The default script will generate a lab with a Windows Server 2016 DataCenter Domain Controller and 4 Windows Server 2016 Core servers ready to be set up with Storage Spaces Direct.)

Default Labconfig

Default Labconfig with collapsed sections (ctrl+M)

Advanced LabConfig (deleted lines 1-16)

Step 4 Right-click and run with PowerShell 1_Prereq.ps1

  • 1_Prereq.ps1 will create a folder structure and will download necessary files from the internet.
  • If your server does not have an internet connection, run this on an internet connected machine, copy created files over ,and run 1_prereq.ps1 again.

Result

Result: Tools folder created

CreateParentDisk tool, DSC modules and ToolsVHD folder

Step 5 (optional) Copy SCVMM files (or your tools) to toolsVHD folder

  • If you modified labconfig.ps1 in Step 3 to deploy SCVMM, populate the temp\ToolsVHD\SCVMM folder. If you downloaded SCVMM trial, run the exe file to extract it. Extract SCVMM Update Rollups (extract MSP files from cabs).

  • You can copy your favorite tools to ToolsVHD, that's always mounted to DC, or to any machine in the lab.

SCVMM Folders in ToolsVHD folder

Step 6 Right-click and run with PowerShell 2_CreateParentDisks.ps1

  • 2_CreateParentDisks.ps1 will check if you have Hyper-V installed, it will prompt you for Windows Server ISO file, and it will ask for packages (provide Cumulative Update and Servicing Stack Update). After, it will hydrate parent disks and Domain Controller.
  • A Domain controller is provisioned using DSC. Requires time to deploy, but after that you do not need to run this step anymore as DC is saved, and returned to previous state before deploy step.

ISO Prompt

MSU Prompt

Result: Script finished

Result: Script cleanup unnecessary folders - before

Result: Script cleanup unnecessary folders - after

Result: Parent disks are created

Result: DC, thats imported during deploy, is Created

Step 7 Right-click and run with PowerShell Deploy.ps1

  • Deploy.ps1 will deploy servers specified by Labconfig.ps1. By default, it will deploy servers for S2D Hyperconverged scenario.

Result

Step 8 Continue with S2D Hyperconverged Scenario

  • S2D Hyperconverged Scenario page
  • You will be guided to deploy 4 Node Storage Spaces Direct cluster.
  • Note: scenario is completely separate script. You use it when logged into DC. Spend time observing what it does as you can easily learn from it. If you are not in rush, run it line by line in PowerShell or PowerShell ISE and use a GUI to observe changes to understand what is happening.

Step 9 Cleanup lab with Cleanup.ps1

  • VMs and switch are identified using prefix defined in LabConfig.
  • All VMs\Switches with prefix are listed.

Step 10 Try different scenarios

  • Scenarios page
  • Just replace LabConfig and Deploy again (takes 5-10 minutes to spin up new VMs).

Tips and tricks

  • In the tools folder, CreateParentDisk.ps1 script is created. You can use this anytime to create additional parent disks (such as Server with GUI or Windows 10). Just right-click and run with PowerShell

  • If you want to run scripts on Server Core, modify labconfig and use ServerISOFolder and ClientISOFolder variables (MSUs are optional).
  • Disable Defender during CreateParentDisks as AMSI is scanning scripts and utilizing the CPU. (Takes twice more time to create parent disks).
  • Every script is creating a transcript file. You can look for issues there.
  • If you want internet connection, just specify Internet=$true in Labconfig.

Known issues

  • DISM does not work on Cluster Shared Volumes.
  • When waiting on DC to come online, the script throws red errors by design. There is nothing to worry about.
  • DISM may throw errors on NTFS volumes. Just build the lab again in different folder.
  • Sometimes if all machines are started at once, some are not domain joined. Just cleanup and deploy again.

So what is it good for?

Simulations such as

  • how to script against servers
  • how to automate configuration
  • what will happen when I run this and that command
  • how change drive in S2D cluster
  • what will happen when one node goes down
  • testing new features before pushing to production
  • ...