Given the portion of script I have below, is there a way to edit the 'Num of VMs' to be only powered on VMs, i'm not sure what to add at the end of $ESXHost.vm.count
Thanks, Dan
$Report = @()
$ESXHosts = Get-VMHost | Sort Name | Get-View
ForEach ($ESXHost in $ESXHosts)
{
$ReportObj = "" | Select Name, "VMotion Enabled", "Connection State", "CPU Used (MHz)", "Total CPU (MHz)", "% CPU Used", "RAM Used (GB)", "Total RAM (GB)", "% RAM Used", "Num of VMs"
$ReportObj.Name = $ESXHost.Name
$ReportObj."VMotion Enabled" = $ESXHost.summary.config.vmotionenabled
$ReportObj."Connection State" = $ESXHost.summary.runtime.connectionstate
$ReportObj."CPU Used (MHz)" = $ESXHost.summary.quickStats.overallCpuUsage
$ReportObj."Total CPU (MHz)" = (($ESXHost.summary.hardware.NumCpuCores)*($ESXHost.summary.hardware.CpuMhz))
$ReportObj."% CPU Used" = "{0:F1}" -f (100(($ESXHost.summary.quickStats.overallCpuUsage)/(($ESXHost.summary.hardware.NumCpuCores)($ESXHost.summary.hardware.CpuMhz))))
$ReportObj."RAM Used (GB)" = "" -f ($ESXHost.summary.quickStats.overallMemoryUsage/1024)
$ReportObj."Total RAM (GB)" = "" -f ($ESXHost.Summary.Hardware.MemorySize/1GB)
$ReportObj."% RAM Used" = "" -f (100*(($ESXHost.summary.quickStats.overallMemoryUsage/1024)/($ESXHost.Summary.Hardware.MemorySize/1GB)))
$ReportObj."Num of VMs" = $ESXHost.vm.count
$Report += $ReportObj
}
$Report | ConvertTo-Html -title "Advanced Host Information" -body "<H4>Advanced Host Information</H4>" | Out-File -Append $filelocation
Nice solution Allan, but I think it should say
$ReportObj."Num of VMs" = (Get-vmhost $ESXHost.name | get-vm | where {$_.Powerstate -eq "PoweredON"} | Measure-Object).Count
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nice solution Allan, but I think it should say
$ReportObj."Num of VMs" = (Get-vmhost $ESXHost.name | get-vm | where {$_.Powerstate -eq "PoweredON"} | Measure-Object).Count
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks both of you for your help, the script is really coming on and it wouldn't be was it not for your input so thank you.
Dan