So I am trying to do it in this format so I can send the output to HTML.
This is the items I found on the discussion board from LucD that I am trying to use
Get-VMHost -Name MyEsx |
Select Name,
@{N='CPU GHz Capacity';E={[math]::Round($_.CpuTotalMhz/1000,2)}},
@{N='CPU GHz Used';E={[math]::Round($_.CpuUsageMhz/1000,2)}},
@{N='CPU GHz Free';E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)}},
@{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}},
@{N='Memory Used GB';E={[math]::Round($_.MemoryUsageGB,2)}},
@{N='Memory Free GB';E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)}}
BUT I need a way to populate the lines below with the correct syntax.
My issue is only on the CPU and Mem portions...
foreach ($vmhost in get-vmhost )
{
$reportedhosts= "" | Select-Object Host, "CPU Capacity", "CPU Used"
$reportedhosts.Host = $vmhost.Name
$reportedhosts."CPU Capacity" = $vmhost.{[math]::Round($_.CpuTotalMhz/1000,2)}
$reportedhosts."CPU Used" = $vmhost.{[math]::Round($_.CpuTotalMhz/1000,2)}
I know I can do for instance:
$reportedhosts."CPU Capacity" = $vmhost.CpuTotalMhz
BUT IT IS NOT ROUNDED.... I WANT IT ROUNDED