Fixing Hyper-V Virtual Machines sticking at 6% starting

A while ago I noticed that when I started virtual machines on Hyper-V on my laptop – they were taking just over a minute to start.  Looking at the Hyper-V management console showed that for most of this time the virtual machine was sitting at “Starting (6%)” under the status column.

After a bit of investigation I discovered that this was the result of a known issue.  When this happens the cause is usually because there is a problem with Hyper-V finding a valid certificate.  To give a bit more context:

When you start a virtual machines, we start a Remote Desktop listener that will allow you to connect to the virtual machine and view the display of the virtual machine.  In order to do this in a secure fashion – we check certificate store on your computer to find the best available certificate to secure the Remote Desktop connection with.

The problem happens when you have certificates in your certificate store that we are unable to validate.

In my case my laptop had certificates on it that could only be validated when I was connected to the Microsoft corporate networks.  When I was at home it was not possible to validate them.

Luckily – there is a relatively simple fix.  One of our developers, Stefan Wernli, has posted a PowerShell script that will identify a valid certificate and configure Hyper-V to always use that certificate – instead of searching for the best certificate each time you start a virtual machine.

You can grab the script from here: https://gallery.technet.microsoft.com/ScriptCenter/en-us/5b4a7114-218b-466c-a9c1-7eb2f725e707

Cheers,
Ben