Fixing Network Adapter settings on Checkpoints

Here is an interesting question from the Hyper-V forums:

https://social.technet.microsoft.com/Forums/en-US/a6012994-de98-41f9-8b96-2139ee2ad631/hyperv-resource-pool-nic?forum=winserverhyperv

In essence – the situation is that the user has:

  1. Created a virtual machine
  2. Connected it to a virtual switch
  3. Taken a checkpoint
  4. Deleted and recreated the virtual switch

Now, whenever they apply the old checkpoint – they get a configuration error message.  They can fix up the virtual machine settings each time – but this is annoying.  However, checkpoints are read-only and there is nothing you can do – right?  Actually, wrong.

Changing the settings on a checkpoint is potentially dangerous – so we disable this through the Hyper-V Management UI.  However, you can reach into the heart of Hyper-V and tinker with checkpoint settings if you know what you are doing.

This problem can be fixed with a little bit of PowerShell know-how.

What we want to do is to get any checkpoints that have network adapters connected to the old virtual switch – and reconnect them to the new virtual switch.  The first task is to get all network adapters associated with checkpoints.  Ordinarily – Get-VMNetworkAdapter will only return network adapters associated with virtual machines.

To get network adapters associated with virtual machine checkpoints – we have to run  Get-VMCheckpoint * | Get-VMNetworkAdapter.  And to fix up the issue reported – we need to run something like this:

Get-VMCheckpoint * | Get-VMNetworkAdapter | ? SwitchName -eq "Old Missing Virtual Switch" | Connect-VMNetworkAdapter -SwitchName "New Virtual Switch"

With the logical substitutions for the virtual switch names – of course.

Cheers,
Ben