Determine the Generation of a Hyper-V VM with PowerShell
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.
1Get-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.
1Get-WindowsFeature -Name *hyper*powershell
The generation of the VM is one of the properties from the results of Get-VM
.
1Get-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.
1Invoke-Command -ComputerName HyperV-Server01, HyperV-Server02, HyperV-Server03 {
2 Get-VM | Select-Object -Property Name, Generation
3} | Select-Object -Property Name, Generation
µ