Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get-VMHost | Sort-Object Name | % {
$hv = $_
$hv_pcpu_count = $hv.NumCpu
$power_on_vms = $hv | Get-VM | where {$_.PowerState -eq "PoweredOn"}
$hv_vcpu_count = ($power_on_vms| Measure-Object -Sum NumCpu).Sum + 0
$hv_oc_percent = $hv_vcpu_count / $hv_pcpu_count * 100
"-----"
$hv.Parent.Name + "/" + $hv.Name + " ConnectionState:" + $hv.ConnectionState
"$hv_pcpu_count pCPU で、$hv_vcpu_count vCPU が起動中です。"
"vCPU: " + ("" * $hv_vcpu_count) + " => オーバーコミット: " + $hv_oc_percent + "%"
"pCPU: " + ("" * $hv_pcpu_count)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment