Skip to content

Getting Started

Codeblack edited this page Oct 23, 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, fork & clone or download the HyperVLab-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

Currently, HyperVLab works only with Windows Server 2016. 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/.

I am working on support for Windows Server 2012 R2.

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. For the Windows Server 2016 Evaluation Edition, this will result in the following:

    Deployment Image Servicing and Management tool
    Version: 10.0.14393.0
    
    Details for image : F:\sources\install.wim
    
    Index : 1
    Name : Windows Server 2016 Standard Evaluation
    Description : This option (recommended) reduces management and servicing by installing only what is needed to run most server roles an
    d applications. It does not include a GUI, but you can fully manage the server locally or remotely with Windows PowerShell or other to
    ols. For more details see "Windows Server Installation Options."
    Size : 8,840,650,521 bytes
    
    Index : 2
    Name : Windows Server 2016 Standard Evaluation (Desktop Experience)
    Description : This option is useful when a GUI is required—for example, to provide backward compatibility for an application that cann
    ot be run on a Server Core installation. All server roles and features are supported. For more details see "Windows Server Installatio
    n Options."
    Size : 14,858,983,050 bytes
    
    Index : 3
    Name : Windows Server 2016 Datacenter Evaluation
    Description : This option (recommended) reduces management and servicing by installing only what is needed to run most server roles an
    d applications. It does not include a GUI, but you can fully manage the server locally or remotely with Windows PowerShell or other to
    ols. For more details see "Windows Server Installation Options."
    Size : 8,905,611,811 bytes
    
    Index : 4
    Name : Windows Server 2016 Datacenter Evaluation (Desktop Experience)
    Description : This option is useful when a GUI is required—for example, to provide backward compatibility for an application that cann
    ot be run on a Server Core installation. All server roles and features are supported. For more details see "Windows Server        Installatio
    n Options."
    Size : 14,857,373,611 bytes
    
    The operation completed successfully.
    
  • 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:\HyperVLab\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:\HyperVLab\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

All the labs-repositories come with an unattend file. So if you're preparing for one of those, you don't need an unattend file. If you're preparing your own lab, download an existing unattend file from one of labs in the 'Labs.Examples' repository, like: https://github.com/CodeblackNL/Labs.Examples/blob/master/Demo.W2016/unattend.xml.

But depending on your needs, you can create an unattend file by hand, or use the Windows System Image Manager to create one.

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.