Performance report through powercli in ESX/ESXi

#For getting output in csv file.

$metrics = “cpu.usage.average”,”mem.usage.average”
$esx = Get-VMHost
$start = (Get-Date).AddDays(-30)

$stats = Get-Stat -Entity $esx -Stat $metrics -Start $start
$stats | Group-Object -Property EntityId | %{
$cpuStat = $.Group | where {$.MetricId -eq “cpu.usage.average”} | Measure-Object -Property Value -Average -Maximum
$memStat = $.Group | where {$.MetricId -eq “mem.usage.average”} | Measure-Object -Property Value -Average -Maximum
New-Object PSObject -Property @{
Name = $_.Group[0].Entity.Name
CpuMax = “{0:f2}” -f $cpuStat.Maximum
CpuAvg = “{0:f2}” -f $cpuStat.Average
MemMax = “{0:f2}” -f $memStat.Maximum
MemAvg = “{0:f2}” -f $memStat.Average
}

} | Export-Csv “C:\esx-stat.csv” -NoTypeInformation -UseCulture

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s