Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active September 18, 2021 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/4b30352f8378a6966f003d295357361c to your computer and use it in GitHub Desktop.
Save gowatana/4b30352f8378a6966f003d295357361c to your computer and use it in GitHub Desktop.
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