designsoliman - Fotolia
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 IT systems management and monitoring
Related Q&A from Nirmal Sharma
Use System Center Virtual Machine Manager and PowerShell to make logical network management easy. Execute a script to display network virtualization ... Continue Reading
Hyper-V replication is easy to use, but there are a number of steps you should take during Hyper-V replication setup to ensure you stay abreast of ... Continue Reading
Manage Hyper-V clusters more easily with PowerShell cmdlets and scripts that automate the retrieval and display of node information, including node ... Continue Reading