Getting hyped over HyperV

I vividly remember going to a VMWare in-person training session in the Melbourne CBD about a decade ago.  Ever since then I've been using their products to manage my individual and company environments and infrastructures.  Just about every customer site uses their products as well.  It costs money to maintain and support, which I don't like.  

I recently stepped through an MCSA study guide and there was a whole section devoted to HyperV (Microsoft's alternative to VMWare).  It was entirely new for me.  I'm impressed how easy it is to setup, use, and manage.  Since it's an integral component of Windows itself, making use of it becomes more interesting as each day arrives.  

For me the best feature is that it's included as a feature of Windows 10 and Windows Server.  That means I can create a VM on my desktop and then migrate it to a development, testing, or production environment.  I don't have to pay for a third-party product to do this.  Considering I rebuild my workstation every 3 months, it's becoming a silent blessing.

Combine that with the fact that I get powershell commands along with the management console, I can now script EVERYTHING!  

Maybe a script to create a new workgroup server virtual machine?

$envName = 'CMRamble'           #Environment Name
$serverType = 'Workgroup'       #Server Type
$vmRoot = "D:\HyperV"           #Where to put the VMs
$vmName = "$($envName) $($serverType)"   #Name of this VM as appears in HyperV
$vmPath =  "$($vmRoot)\$($envName)"    #Storage Location of VMs in Root Path
$vhdPath = Join-Path $vmPath "$($vmName)\Virtual Hard Disks\$($serverType).vhdx"    #Storage Location of HD for VM
$vSwitch = "$($envName)"        #Virtual Switch Name
$osPath = "D:\Software\en_windows_server_2016_x64_dvd_9718492.iso"   #Storage Location of Operating System
#Find existing or create new VM
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
if ( $vm -eq $null ) {
    New-VM -Name $vmName -Path $vmPath -MemoryStartupBytes 512MB -SwitchName $vSwitch -Generation 2
#Create new virtual hard disk if needed
if ( (Test-Path $vhdPath) -eq $false) {
    New-VHD -Path $vhdPath -SizeBytes 60GB -Dynamic 
#Attach vhd
Add-VMHardDiskDrive -VMName $vmName -Path $vhdPath
#Get or create DVD drive
$dvd = Get-VMDvdDrive -VMName $vmName
if ( $dvd -eq $null ) {
    $dvd = Add-VMDvdDrive -VMName $vmName
#Set DVD to boot first
Set-VMFirmware -VMName $vmName -FirstBootDevice $dvd
#Point the DVD to the OS
if ( (Test-Path $osPath) -eq $true ) {
    Set-VMDvdDrive -VMName $vmName -Path $osPath -ToControllerNumber 0 -ToControllerLocation 1
#Dodgy firmware fix that seemed to fix something
Get-VM $vmName|Get-VMFirmware|ForEach {Set-VMFirmware -BootOrder ($_.Bootorder | ? {$_.BootType -ne 'File'}) $_}

Then more scripts that start it, configure the OS, install Content Manager, and copy the software configuration files to it. After running all these scripts the VM is ready to be added within the Enterprise Studio!  Pretty cool to be able to have a new environment fully ready in just a few minutes.

Moving the VM to another server is super easy.  I right-click on the VM and select Move.  Then specify the name of the destination server and select where on that server it should be placed.  I'm placing this VM on the "D:\" partition, which I happen to know is a massive SSD (makes a big difference with HyperV).  

I didn't stop-watch it, but it seems to have taken 10 minutes or so for this 20 GB VM.  Best part is that my Content Manager Virtual Machine had no down-time.  

Moving a VM from one server to another is quite easy

Moving a VM from one server to another is quite easy



You may get the error message below when you attempt to kick off a move.  If you did, you need to initiate the move on the source server directly (and not by connecting the HyperV console to another server).


Adding HyperV to your workstation

First I right-click on the start-menu and select Programs and Features


Then I click the Programs and Features link in the Related settings section of the right-hand pane.


Then I click Turn Windows features on or off


Then I find and enable both the HyperV features


I let it finish and restart my system