Hello All,
As i mentioned earlier i am beginner in powercli and i was looking at some scripts about the cluster level stats.. With a Kind help of LucD i am able to generate a scrip to generate cluster level Memory and CPU stats, how ever i am trying to get the below list of information through powercli script and i have got some ideas from this community and generated the below script which is giving hell a lot of errors. can some one help in getting the below output.....
Note: I have a vcenter version 4.0,5.0, so i am looking for the commandlets which supports both the version.
$report = @()
$cluster = Get-Cluster
$esx = $cluster | Get-VMHost
$vm = $cluster | Get-VM Where-Object {$_.PowerState -eq "Powered On"}
$vmoff = $cluster | Get-VM Where-Object {$_.PowerState -eq "Powered Off"}
$ds = Get-Datastore | where {$_.Type -eq "VMFS"}
$CPUMhzAvg = $_.Group | where {$_.MetricId -eq "cpu.usagemhz.average"} | Measure-Object -Property value -Average
$MemoryConsumedavg = $_.Group | where {$_.MetricId -eq "mem.consumed.average"} | Measure-Object -Property value -Average
New-Object PSObject -Property @{
$row = "" | Select ClusterName, Numberofhosts,VMon, VMoff, TotalDiskSpace(GB), AvailableDiskSpace(GB), Total Physical Memory (MB), MemoryConsumedavg
Total CPU (Mhz), CPUMhzAvg
$row.ClusterName = $cluster.Name
$row.Numberofhosts = $esx.count
$row.VMon = $vm.count
$row.vmoff = $vmoff.count
$row.TotalDiskSpaceGB = ($ds | Measure-Object -Property CapacityGB -Sum).Sum
$row.AvailableDiskSpaceGB = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum
$row.Total Physical Memory (MB) = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum
$row.MemoryConsumedavg = $MemoryConsumedavg.Average
$row.Total CPU (Mhz) = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum
$row.CPUMhzAvg = $CPUMhzAvg.Average
$report += $row
}
$report | Export-Csv "C:\Documents and Settings\Desktop\Cluster123.csv" -NoTypeInformation -UseCulture
Can some one help me in the above script!!!
$report = @() $clusters = Get-Cluster foreach ($cluster in $clusters) { $esx = $cluster | Get-VMHost $vm = $cluster | Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} $vmoff = $cluster | Get-VM | Where-Object {$_.PowerState -eq "PoweredOff"} $ds = Get-Datastore | where {$_.Type -eq "VMFS"} $CPUMhzAvg = $cluster | Get-Stat -Stat cpu.usagemhz.average | Measure-Object -Property value -Average $MemoryConsumedavg = $cluster | Get-Stat -Stat mem.consumed.average | Measure-Object -Property value -Average $row = @{} $row.'ClusterName' = $cluster.Name $row.'Numberofhosts' = $esx.count $row.'VMon' = $vm.count $row.'vmoff' = $vmoff.count $row.'TotalDiskSpaceGB' = ($ds | Measure-Object -Property CapacityGB -Sum).Sum $row.'AvailableDiskSpaceGB' = ($ds | Measure-Object -Property FreeSpaceMB -Sum).Sum $row.'TotalPhysicalMemory(MB)' = ($esx | Measure-Object -Property MemoryTotalMB -Sum).Sum $row.'MemoryConsumedavg' = $MemoryConsumedavg.Average $row.'TotalCPU(Mhz)' = ($esx | Measure-Object -InputObject {$_.CpuTotalMhz - $_.CpuUsageMhz} -Sum).Sum $row.'CPUMhzAvg' = $CPUMhzAvg.Average $object = New-Object -TypeName psobject -Property $row $report += $object } $report
Thanks a ton Kunal,
I need latest inventory (VM off, VM on, Total CPU, Memory, Disk) of 30 last days, along with 30 days average CPU & Memory usage value also i need maximum obtained memory and cpu in those 30 days
Helo Kunal.. Can you help me with that...