Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hyper-V 2016 Best Practices

You're reading from   Hyper-V 2016 Best Practices Harness the power of Hyper-V 2016 to build high-performance infrastructures that suit your needs

Arrow left icon
Product type Paperback
Published in Oct 2016
Publisher Packt
ISBN-13 9781785883392
Length 246 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Benedict Berger Benedict Berger
Author Profile Icon Benedict Berger
Benedict Berger
Romain Serre Romain Serre
Author Profile Icon Romain Serre
Romain Serre
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Accelerating Hyper-V Deployment 2. Deploying Highly Available Hyper-V Clusters FREE CHAPTER 3. Backup and Disaster Recovery 4. Storage Best Practices 5. Network Best Practices 6. Highly Effective Hyper-V Design 7. Hyper-V Performance Tuning 8. Management with System Center and Azure 9. Migration to Hyper-V 2016

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

Creating virtual machines

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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime