Windows 2012 R2 - We couldn't complete the updates

Running a Windows 2012 R2 Server in Hyper-V as a gen2 machine.
Make sure to switch off 'secure boot' in the VMMachine settings as otherwise you are likely to get the following issue with installing updates:

It'll get stuck in a reboot loop: We couldn't complete the updates. Undoing changes, Don't turn off your computer"

Urrgggghhh. So switch off secure boot, then if it doesn't fix itself, use this process:

Set the 'Auto Start' options for the VM in hyper-v to have a delay of 5 seconds.

-Start tapping for F8 when Windows boots and click "Repair your computer".
(Alternatively you can also boot from the Windows Server 2012 R2 ISO/DVD and choose repair.)
-Go in to the Troubleshoot options then choose "Command Prompt".
-Enter your recovery password if asked to do so.
-At the command prompt type "diskpart" to enter the diskpart tool
-Then type "list volume" to show the current volumes. Note down the drive letter that relates to your servers primary drive.
-Type "exit" to exit the diskpart tool.
-Now type the following being sure to change D to the drive letter from the previous step.

-move d:\Windows\WinSXS\Pending.xml d:\Windows\WinSXS\Pending.old

-This will remove the xml that details any pending updates.
-Exit the command prompt and reboot your server.

The server will probably reboot several times as it tries to recover, but it should be good after a few reboots.