Skip to content
/ WSLab Public
forked from microsoft/MSLab

Windows Server rapid lab deployment scripts

License

Notifications You must be signed in to change notification settings

ddugi/WSLab

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 with some of the other available lab automation systems as the project is based on well-crafted 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!

  • Want to try Windows Server insider builds? Check this page

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)

Windows Server 2016

or Windows Server 2019

or Windows Server Insider Preview

Optionally you can download SCVMM 1807 files

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

Step 2 Create folder and Unzip scripts there

Step 3 (Optional) Check the LabConfig.ps1

  • Edit it to specify the lab setup that you require (such as different domain name, Domain Admin name...) This script file documents the detailed configuration options that are available. (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 folder structure and downloads some additional necessary files from internet
  • If you don't have an internet connection on your server, run this on 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 also deploy SCVMM, populate the temp\ToolsVHD\SCVMM folder. If you downloaded SCVMM trial, run the exe file to extract it. Also extract SCVMM Update Rollups (extract MSP files from cabs)

  • You can also copy your favorite tools you would like to have in ToolsVHD, thats always mounted to DC, or optionally to any machine in 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 that it will hydrate parent disks and Domain Controller.
  • Domain controller is provisioned using DSC. Takes some time, but after that you do not need to run this step anymore as DC is saved, used for deploy and then 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 as specified in Labconfig.ps1 By default, it will deploy servers for S2D Hyperconverged scenario

Result

Step 8 Continue with S2D Hyperconverged Scenario

  • S2D Hyperconverged Scenario page
  • will guide you to deploy 4 Node Storage Spaces Direct cluster.
  • Note: scenario is completely separate script. You use it when logged into DC. Take your time and look 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 look with GUI what has changed to fully understand what's happening.

Step 9 Cleanup lab with Cleanup.ps1

  • VMs and switch is 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 tools folder is CreateParentDisk.ps1 script 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 it utilizes CPU. (Takes twice more time to create parent disks)
  • every script is creating 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 some red errors. It's by design, nothing to worry about.
  • DISM sometimes throws errors on NTFS volumes also. 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
  • ...

About

Windows Server rapid lab deployment scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 100.0%