VMware Cloud Community
CoffeeBlackest
Contributor
Contributor
Jump to solution

Powercli - Report pulling a name and current used mhz

Can i add in current cpu used mhz to a powercli script similar to Host CPU from export?  I see ways to come up with the max cpu mhz per cpu, the number of cores, cores per cpu...etc, but i'm not sure how to pull current used cpu mhz...  To restate a different way, i'm not looking for the max cpu in mhz of a single core within a cluster, but for the current usage in mhz of a vm in a cluster.  This would get pulled hourly or so, the MHz listed below is currently pulling the max mhz of a single core, which isn't what i'm after.  When i do a manual export from vcenter, i see Host CPU listed as the heading when i export...but haven't had any luck guessing the name properly (or i fat fingered the right name...or something).

$cluster = "MyTESTCluster"

$report = foreach($esx in Get-VMHost -Location $cluster)
{

foreach($vm in Get-VM -Location $esx)
{

$obj = New-Object PSObject -Property @{
VM = $vm.Name
CPUs = $vm.NumCPU
Mhz = $vm.VMHost.CpuTotalMhz / $vm.VMHost.NumCpu

}
$obj

}

}

$report | Select VM,CPUs,Mhz | Export-Csv -Path .\report090321_test1.csv -NoTypeInformation -UseCulture

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

Get-VM |
Select Name,@{N='CPUDemandMhz';E={$_.ExtensionData.Summary.QuickStats.OverallCpuDemand}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

Get-VM |
Select Name,@{N='CPUDemandMhz';E={$_.ExtensionData.Summary.QuickStats.OverallCpuDemand}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

CoffeeBlackest
Contributor
Contributor
Jump to solution

Perfect...for anybody who wants it...added on a date change to the end of the file so it creates new files each time (rather then appending or overwriting to the same).  Thanks LucD

$AddDateTimeStamp = Get-Date -Format MMddyyyy_HHmm
$cluster = "TEST"
$report = foreach($esx in Get-VMHost -Location $cluster)
{

foreach($vm in Get-VM -Location $esx)
{

$obj = New-Object PSObject -Property @{
VM = $vm.Name
CPUs = $vm.NumCPU
Mhz = $vm.ExtensionData.Summary.QuickStats.OverallCpuDemand

}
$obj

}

}

 

$report | Select VM,CPUs,Mhz | Export-Csv -Path .\testvm$AddDateTimeStamp.csv -NoTypeInformation -UseCulture

0 Kudos