Skip to content

Instantly share code, notes, and snippets.

@edib
Created October 11, 2016 08:20
Show Gist options
  • Save edib/a849600bf6b664a01c91e21aec834ecf to your computer and use it in GitHub Desktop.
Save edib/a849600bf6b664a01c91e21aec834ecf to your computer and use it in GitHub Desktop.
&{ ForEach ($esx in Get-VMHost) {
$vCPU = Get-VM -Location $esx | Measure-Object -Property NumCpu -Sum | select -ExpandProperty Sum
$esx | Select Name,
@{N='pCPU cores available';E={$_.NumCpu}},
@{N='vCPU assigned to VMs';E={$vCPU}},
@{N='Ratio';E={[math]::Round($vCPU/$_.NumCpu,1)}},
@{N='CPU Overcommit (%)';E={[Math]::Round(100*(($vCPU - $_.NumCpu) / $_.NumCpu), 1)}}
} } | Export-Csv report.csv -NoTypeInformation -UseCulture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment