Project “Lift and Shift”–Phase 1: Triage

This is the first blog post in what is going to be a series that I am tagging “Lift and Shift”.

Recently, I had an experience that I know many people have had.  I discovered that my parents were approaching the age where it is no longer possible for them to safely live in their own house, without close support.  As my siblings and I started working through the process of figuring out how to ensure they were well looked after – I came across a somewhat unique problem.

Namely, my father has a substantial server infrastructure running in his house.  Specifically – he has three Hyper-V servers with dozens of virtual machines that operate the business infrastructure for a number of local businesses and family friends.  And it fell to me to figure out how we could safely, quickly shutdown this infrastructure without leaving anyone in the lurch.

This blog series is documenting the process that I am following to get this up and running.

So – where do we start?  Well, the first place to start is in understanding what we have to move.  The problem that I encountered here is that my fathers infrastructure had grown organically over the last couple of years, and no one was really sure about what was running where, and what was needed.

The approach I took here was to get on the phone with my father, connect to his systems with PowerShell, and start triaging.

The first thing I wanted to do was to identify any virtual machines that could just be deleted immediately.  To do this I ran the following chunk of code:

 Remove-Module Hyper-V
Import-Module Hyper-V -RequiredVersion 1.1
$servers = @("WS08Core", "whvs12r21", "whvs12r23")
get-vm -ComputerName $servers | ? state -eq off | ? ReplicationMode -ne Replica

What this block of code does is:

  • Load the Hyper-V module for managing Windows Server 2012 R2
  • Create an array of all the Hyper-V Servers in my fathers environment
  • List all virtual machines that are off, but are not replicated virtual machines

We were able to delete most of the virtual machines that turned up in this list.

The second task was to go through each running virtual machine, and discuss what it did.  As we talked – I put notes in the virtual machine notes.  In this process we identified a number of virtual machines that we wanted to keep – but should be kept local as they were personal development virtual machines.

Finally, I needed to understand how much resource was needed for the running virtual machines that needed to be moved off-premises.  For this I ran this code:

 $exclude = @("funnelweb", "cobol", "rubytest", "timstest", "centos6core")
get-vm -ComputerName $servers | ? ReplicationMode -ne Replica | ?{!$exclude.Contains($_.Name)} | select MemoryAssigned | Measure-Object -sum MemoryAssigned | %{$_.sum / 1GB}
get-vm -ComputerName $servers | ? ReplicationMode -ne Replica | ?{!$exclude.Contains($_.Name)} | Get-VMHardDiskDrive | %{get-vhd -Path $_.Path -ComputerName $_.ComputerName} | select FileSize | %{[long]$_.FileSize} | measure-object -sum | %{$_.sum / 1GB}

What this code does is:

  • Create an array of virtual machines that I do not want to look at
  • Get all virtual machines that are not replicas and are not in the excluded virtual machine set – and return the total Memory and Disk used by the virtual machines

When this was done I knew that we had a set of virtual machines that used about 58GB of RAM and 2.1 TB of disk.

The next challenge was to figure out where to move this to.

Cheers,
Ben