Practice Exams for Windows

Practice Exams for Windows

Saturday, 19 February 2011

Determine Hyper-V Logical to Physical Processor Ratio using Windows PowerShell

According to the Hyper-V team, the ideal logical to physical processor ratio is between 4 and 8. Many Hyper-V servers run well below this level. Use the following PowerShell script to determine the logical to physical ratio on your Hyper-V server/s:

try {
$Virtual_Processors = (Get-WmiObject -Namespace root\virtualization MSVM_Processor -ErrorAction Stop).Count
$Logical_Processors = (Get-WMIObject Win32_Processor -ErrorAction Stop | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum
$Ratio = $Virtual_Processors / $Logical_Processors
if ($Ratio -lt 4) {
Write-Host "$Ratio Virtual Processor(s) per Logical Processor" -ForegroundColor Red
Write-Host "Your Logical to Physical Processor ratio is lower than the recommended value."
} elseif ($ratio -gt 8) {
Write-Host "$Ratio Virtual Processor(s) per Logical Processor" -ForegroundColor Red
Write-Host "Your Logical to Physical Processor ratio is higher than the recommended value."
} else {
Write-Host "$Ratio Virtual Processor(s) per Logical Processor" -ForegroundColor Green
Write-Host "Your Logical to Physical Processor ratio is in the ideal range"
}
}
catch {
Write-Host "WMI call failed. This script must be run on a Hyper-V Server." -ForegroundColor Red
}



When you run this script on a Hyper-V server, you will get an output similar to:



image



This script could be easily modified to check a remote server or a list of remote servers. There is also some redundant code in the script that could be removed or reduced.

No comments:

Post a Comment