Hi , there!
Can somebody help me with PowerCLI script to find out average CPU and Memory hosts utilization during period of time?
Thanks
You could do something like this
$start = $now.AddDays(-7)
$finish = $now
$SStat = @{
Entity = Get-VMHost
Stat = 'cpu.usage.average', 'mem.usage.average'
Start = $start
Finish = $finish
Instance = '*'
ErrorAction = 'SilentlyContinue'
}
Get-Stat @sStat |
Group-Object -Property { $_.Entity.Name } |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
Host = $_.Name
Start = $start
Finish = $finish
CpuAvgPerc = [math]::Round(($_.Group | where { $_.MetricId -eq 'cpu.usage.average' } | Measure-Object -Property Value -Average).Average, 1)
MemAvgPerc = [math]::Round(($_.Group | where { $_.MetricId -eq 'mem.usage.average' } | Measure-Object -Property Value -Average).Average, 1)
})
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this
$start = $now.AddDays(-7)
$finish = $now
$SStat = @{
Entity = Get-VMHost
Stat = 'cpu.usage.average', 'mem.usage.average'
Start = $start
Finish = $finish
Instance = '*'
ErrorAction = 'SilentlyContinue'
}
Get-Stat @sStat |
Group-Object -Property { $_.Entity.Name } |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
Host = $_.Name
Start = $start
Finish = $finish
CpuAvgPerc = [math]::Round(($_.Group | where { $_.MetricId -eq 'cpu.usage.average' } | Measure-Object -Property Value -Average).Average, 1)
MemAvgPerc = [math]::Round(($_.Group | where { $_.MetricId -eq 'mem.usage.average' } | Measure-Object -Property Value -Average).Average, 1)
})
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, Luc.
But how can I get information for business hours in first 7 working days (per every day) in a specific month. And export it to xlsx.
Please help with a script.
I have a section on that in my PowerCLI & VSphere Statistics – Part 2 – Come Together post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, Luc. I'll try