Skip to content

Getting Started

Codeblack edited this page Oct 22, 2016 · 8 revisions

It takes a couple of steps to get started with HyperVLab:

  • Install the HyperVLab PowerShell module
  • Create a base-image from Windows Server installation media, and an unattend-file
  • Create a simple environment

Install the HyperVLab PowerShell module

If you’re not on Windows 10 or Windows Server 2016, install PowerShell 5 by installing WMF 5.0: https://www.microsoft.com/en-us/download/details.aspx?id=50395.

Next, clone or download the repository. Then either copy the module to one of the module-locations (e.g. ‘C:\Program Files\WindowsPowerShell\Modules’), or import it using the full path to the HyerVLab.psd1 file.

Create a base-image

HyperVLab uses base-images to quickly create virtual machines. A base-image is a virtual harddisk that has been ‘sysprepped’. Sysprep is a tool, available in all Windows installations, that removes any unique information from the installation, so it can be reused. When a machine with a sysprepped disk is started, the standard setup process is followed to create a new installation. By providing an unattend-file, the setup process can be fully automated.

The easiest way to create a sysprepped base-image, is to get one from an installation medium. Each iso for Windows Server contains multiple sysprepped images.

1. Download a Windows Server iso

Windows Server 2016 or 2012 R2 will both work. You can download an official version if you have an MSDN subscription, otherwise download an evaluation version here: https://www.microsoft.com/en-gb/evalcenter/evaluate-windows-server-2016/.

2. Determine which images are available

  • Mount the downloaded iso. The following example assumes you downloaded the Windows Server 2016 Evaluation Edition to 'D:\HyperVLab\Media'. The iso filename may be different, as newer releases are provided by Microsoft.

    Mount-DiskImage -ImagePath 'D:\HyperVLab\Media\14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO'
    
  • Run the following command; where F:\ is the drive of the mounted iso, which you may need to change.

    dism /Get-imageinfo /imageFile:F:\sources\install.wim
    
  • This will result in a list of images, with their names & indexes.

  • Take note of the index(es) of the image(s) you want.

  • Dismount the image

    Dismount-DiskImage -ImagePath ‘D:\HyperVLab\Media\14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO’
    

3. Create a virtual harddisk

  • Install the WindowsImageTools PowerShell module (https://github.com/BladeFireLight/WindowsImageTools).

    Install-Module WindowsImageTools
    
  • Create one or more virtual harddisks using the Convert-Wim2VHD command from the WindowsImageTools module. The following example creates base-images for 'Windows Server 2016 Standard'; the first for the GUI-edition, and the second for the Core-Edition. It assumes the same download location for the iso as before.

    Convert-Wim2VHD -Path 'D:\HyperV\Images\W2016_EVAL_GUI.vhdx' -Index 2 -Size 64GB -DiskLayout UEFI -Dynamic -SourcePath 'D:\HyperVLab\Media\14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO' Convert-Wim2VHD -Path 'D:\HyperV\Images\W2016_EVAL_CORE.vhdx' -Index 1 -Size 64GB -DiskLayout UEFI -Dynamic -SourcePath 'D:\HyperVLab\Media\14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO'

4. Create an unattend file

Depending on your needs, you can create an unattend file by hand, use the Windows System Image Manager to create one, or download one an existing one from one of the 'Labs.Examples' repository.

TODO: add unattend-file(s) to repo; add links here.

Create a simple environment

TODO: describe how to get started with the environments from the 'Labs.Examples' repository.
IN PROGRESS: create the environments from the 'Labs.Examples' repository.

Clone this wiki locally