Production VMs need to be configured with sufficient system resources, including Hyper-V virtual processors, to...
ensure applications that require processing power work efficiently, and that the needed processing power is available throughout the VM's runtime.
To ensure VMs are configured with the correct number of Hyper-V virtual processors, you can open either Hyper-V Manager or System Center Virtual Machine Manager, but you need to open the configuration page of each VM to see the virtual processors configured for it. If you have several VMs configured on your hosts, this process can be quite tedious.
Alternatively, you can use one-liner PowerShell commands and a PowerShell script to show Hyper-V virtual processors configured for VMs.
Check VMs on the local host
If you want to see the Hyper-V virtual processors configured for a single VM, just execute Get-VMProcessor -VMName SQLVM. This command displays the number of Hyper-V virtual processors configured to the SQLVM.
If you want to see the Hyper-V virtual processor counts for all the VMs on the local host, just execute Get-VMProcessor -VMName *. Using * in the PowerShell command helps retrieve processor counts for all the VMs.
Check VMs on remote servers
While the commands above help gather Hyper-V virtual processor counts for VMs running on the local host, the PowerShell script below can be used to retrieve Hyper-V virtual processors counts for all the VMs running on remote servers listed in a text file.
$HyperVHost = "C:\Temp\HyperVHosts.TXT"
$ReportFile = "C:\Temp\ProcessorReport.CSV"
Remove-item $ReportFile -ErrorAction SilentlyContinue
Foreach ($ThisHost in Get-Content "$HyperVHost")
Get-VMProcessor -ComputerName $ThisHost -VMName * | Export-CSV $ReportFile -Append
Write-Host "Script finished collecting Virtual Processors for Hyper-V Servers. Please check $ReportFile"
The PowerShell script above uses C:\Temp\HyperVHosts.TXT, in which Hyper-V server names are mentioned, and then runs the Get-VMProcessor PowerShell command against each Hyper-V server it retrieves from the file.
Once the output is retrieved, it's saved in the C:\Temp\ProcessorReport.CSV file. The -Append parameter in the Export-CSV command appends the output to the existing file.
Dig Deeper on Microsoft Hyper-V management
Related Q&A from Nirmal Sharma
There isn't a set number of virtual processors you should configure for a Hyper-V VM, but there are steps you can take to ensure your workloads ... Continue Reading
VHD File Set -- a file format new to Windows Server 2016 -- is helpful for IT administrators using guest clusters. Get up to speed on the basics and ... Continue Reading
Download and install Microsoft Virtual Machine Converter to gain access to several PowerShell commands that enable VMware VMDK to Hyper-V VHDX ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.