Skip to content

Instantly share code, notes, and snippets.

View wolruf's full-sized avatar

Olivier wolruf

  • Cloudflare
  • France
  • 04:15 (UTC +02:00)
  • X @wolruf
View GitHub Profile
$vserver = Read-Host -Prompt 'Enter vCenter Server FQDN or IP address'
$creds = get-credential
Connect-VIServer $vserver -Credential $creds
Get-VM | Select Name, VMHost, NumCpu, MemoryMB, `
@{N="ProvisionedSpace (GB)"; E={[math]::Round($_.ProvisionedSpaceGB)}}, `
@{N="UsedSpace (GB)"; E={[math]::Round($_.UsedSpaceGB)}}, `
@{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}, `
@{N="CPU Usage (Max), MHz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Maximum).Maximum),2)}}, `
@{N="MaxHostCpuMhz" ; E={$_.NumCpu * $_.VMHost.CpuTotalMhz / $_.VMHost.NumCpu}}, `