Book Image

Hyper-V 2016 Best Practices

By : Romain Serre, Benedict Berger
Book Image

Hyper-V 2016 Best Practices

By: Romain Serre, Benedict Berger

Overview of this book

Hyper-V Server and Windows Server 2016 with Hyper-V provide best-in-class virtualization capabilities. Hyper-V is a Windows-based, very cost-effective virtualization solution with easy-to-use and well-known administrative consoles. This book will assist you in designing, implementing, and managing highly effective and highly available Hyper-V infrastructures. With an example-oriented approach, this book covers all the different tips and suggestions to configure Hyper-V and provides readers with real-world proven solutions. This book begins by deploying single clusters of High Availability Hyper-V systems including the new Nano Server. This is followed by steps to configure the Hyper-V infrastructure components such as storage and network. It also touches on necessary processes such as backup and disaster recovery for optimal configuration. The book does not only show you what to do and how to plan the different scenarios, but it also provides in-depth configuration options. These scalable and automated configurations are then optimized via performance tuning and central management ensuring your applications are always the best they can be.
Table of Contents (15 chapters)
Hyper-V 2016 Best Practices
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface

Creating virtual machines


You are all set, and it's time to create some virtual machines. To do a rapid deployment of virtual machines, we will rely on PowerShell.

Creating a new virtual machine with PowerShell is easy; just open an elevated PowerShell prompt, and run the following command:

New-VM

Without any additional parameters, this will create a new virtual machine with the default parameters. To create a new Generation 2 VM, run the following command:

New-VM -Generation 2

To create a new virtual machine with a specified name, a custom path to store the VM files, and a memory configuration, run the following command:

New-VM -Name VM01 -Path C:\VM01 -Memorystartupbytes 1024MB

Your newly created virtual machine doesn't have a hard disk yet. Create a new VHDX file by running the following command:

New-VHD -Path C:\vms\vm01\vm01_c.vhdx -SizeBytes 60GB -Dynamic

The VHD cmdlet

The created VHDX is not yet attached to a virtual machine. Do this by running the following command:

Add-VMHardDiskDrive -VMName VM01 -Path C:\vms\vm01\vm01_c.vhdx

To add a network adapter to our virtual machine, run the following command:

Add-VMNetworkAdapter -vmname "VM01" -switchname "external"

Then, start the VM by running the following command:

Start-VM -Name VM01

You will recognize that the virtual machine now has all the basic hardware parameters but fails to boot due to a missing operating system. There are multiple ways to create an operating system for a standard VM. The most granular way to achieve this is using Virtual Machine Manager templates (refer to Chapter 8, Management with System Center and Azure, for details), but there are great capabilities already included in Windows Server 2016. The approach that is seen most often is to manually install the first virtual machine and include everything you want in each of your virtual machines, such as operating system, updates, and backup agents. Then, sysprep the virtual machine by executing sysprep.exe present at C:\Windows\System32\sysprep\ with the Generalize and OOBE options and shut down the virtual machine. Copy it to a Template folder and mark this as read only. As of Windows Server 2016, you can even copy and export running virtual machines.

If you need a new virtual machine, just copy the Template folder, rename it with your machine name and a preinstalled operating system with all your previous created configurations are still available. 

If you don't like patching all your images and archived VMs manually, you can use a solution to update these VHD/VHDx files offline with Apply-WindowsUpdate.ps1-just another gem from the TechNet Gallery (download this from the shortlink, http://bit.ly/1o4sczI).

As you have seen in this chapter, I have mainly used Generation 2 VMs. If your guest operating systems are Windows Server 2012 and higher, this should be your default option. Generation 2 VMs allow faster booting, better stability, and smaller attack surface through a greatly reduced set of legacy hardware.