Today we are going to solve how to use nested virtualization within a Hyper-V environment in Windows 10, 11, or higher.
Nested virtualization is a technique that allows running virtual machines (VMs) inside another VM. That is, a VM inception. A Russian doll of VMs.

And why would we want to do this? To be life’s geeks who amuse themselves? Well yes, that too, … but not only for that.
Actually, it’s easier than you think to get into this situation: for example, if you are using a virtual machine for development, or a virtual machine to test other virtual machines.

But more than that, you might need it simply by using Windows Subsystem for Linux (WSL) or Windows Subsystem for Android (WSA) on a virtual machine.
Because WSL and WSA are great tools that internally use virtualization to work. So if you use a virtual machine for development… oh, oh! You’re going to have a little problem.
Fortunately, it’s very easy to enable nested virtualization. First, open a command console and get a list of your virtual machines with this command,
Get-VM

We make sure the machine on which we want to enable nested virtualization is stopped. If not, we stop it with this command.
Stop-VM -Name ‘your-vm-name’
Where, of course, you will have to change ‘your-vm-name’ to the name of the machine you want to work with.
The VM configuration must be version 8.0 or higher. In any case, and just to be safe, we update the virtual machine with this command,
Update-VMVersion -Name ‘your-vm-name’
Finally, now we enable nested virtualization on the virtual machine with this command.
Set-VMProcessor -VMName ‘your-vm-name’ -ExposeVirtualizationExtensions $True
We restart our VM. Now we can access it and proceed to install the Hyper-V role or feature and any other dependent on it. With nested virtualization enabled, we will be able to run virtual machines inside the host VM and test different virtualization environments.
This option is very useful for testing different virtualization environments and doing integration tests with different operating systems. And as we have seen, it’s a matter of a couple of commands to activate it.

