Hyper-V - How to install Ubuntu as a Generation 2 Guest
Every time I set up a Ubuntu Hyper-V Generation 2 Guest, I forget something. You need to disable secure boot. To do this, you can do this in a couple of ways.
GUI
In the GUI of the VM go to Security and disable “Secure Boot”. The VM has to be stopped to unselect the option. If you don’t stop the VM it will look greyed out like in the image below.
PowerShell
The commands are just as fast!
First command - Get the name of the VMs hosted in Hyper-V and find the name of the VM you need.
Get-VM | Get-VMFirmware
I can see the VM’s name is “Ubuntu-docker”
Second Command - This next Cmdlet grabs the VM as an object and then pipes it to the “Set-VMfirmware” Cmdlet. The piped Cmdlet turns off the SecureBoot.
Get-VM -Name 'Ubuntu-docker' | Set-VMFirmware -EnableSecureBoot Off
There you go! Now you can install it as easy as 1,2,3.