Ever need to determine what generation all of the virtual machines are on your Hyper-V servers? This is simple using the Get-VM command that installs as part of the Hyper-V module for Windows PowerShell.
1 | Get-WindowsOptionalFeature -FeatureName *hyper*powershell -Online |
While the previous command will work on both clients and servers, the following command could also be used on a Windows server.
1 | Get-WindowsFeature -Name *hyper*powershell |
The generation of the VM is one of the properties from the results of Get-VM.
1 | Get-VM | Select-Object -Property Name, Generation |
The previous example is a list of all the VM’s on my local Windows 10 system that has the Hyper-V role installed. This same command will work on Hyper-V servers and it can always be wrapped inside of Invoke-Command to have it run against numerous remote Hyper-V servers in parallel.
1 2 3 | Invoke-Command -ComputerName HyperV-Server01, HyperV-Server02, HyperV-Server03 { Get-VM | Select-Object -Property Name, Generation } | Select-Object -Property Name, Generation |
Thoughts, questions, comments? Please post them as a comment to this blog article.
µ
The primary difference between Gen1 and Gen2 is the difference between BIOS and UEFI boot
If the OS supports UEFI boot make the VM Gen2
Other differences are what you can do to the VM live vs having to shut it down to add things like CPU and RAM
From within a VM, to detect whether it is Gen1 or Gen2, look at Win32-BIOS.Description. If it includes the string “UEFI”, then it is a Gen2 VM. If not, it is Gen1. (You can also look at Win32-BIOS.Manufacturer – Gen1 is “American Megatrends Inc.” whereas Gen2 is “Microsoft Corporation”.)