overall VM Utilization summary

This post was originally published on this site

Hi All,

 

I’m trying to pull the VM utilization summary report for all the VM’s in the below format, but it throws an error. Any pointers will be much appreciated.

 

Name vCPU Utilization % (Peak) Utilization % (Avg) Memory (GB) Utilization % (Peak) Utilization % (Avg) Disk Space (GB) Utilization % (Peak) Utilization % (Avg) vNIC Utilization MBps (Peak) Utilization MBps (Avg)

 

 

# VM Utilisation Summary ###

 

$encrypted = Get-Content D:Scriptsscriptsencrypted_paswd_admin.txt | ConvertTo-SecureString

$Cred = New-Object System.Management.Automation.PsCredential($userbane, $encrypted)

 

$Cred = New-Object System.Management.Automation.PsCredential($userbane, $encrypted)

 

 

$vCenters = (Get-Content “C:TempVC2.txt”)

 

 

$performance = @()

 

 

foreach ($vcenter in $vcenters) {

 

 

   Connect-VIServer $vcenter -Credential $Cred

 

 

   }

 

 

$performance += Get-Stat -Entity $vms -Start $start -ErrorAction SilentlyContinue |

 

Group-Object -Property {$_.Entity.Name} |

 

 

Select @{N=’VM’;E={$_.Name}},

 

 

    @{N=’Cluster’;E={(Get-Cluster -VM $_.Name)}},

    @{N=’CPU(%)’;E={“{0:N1}” -f ($_.Group | where{$_.MetricId -eq ‘cpu.usage.average’} | Measure-Object -Property Value -Average | select -ExpandProperty Average)}},

 

 

    @{N=’Memory(%)’;E={“{0:N1}” -f ($_.Group | where{$_.MetricId -eq ‘mem.usage.average’} | Measure-Object -Property Value -Average | select -ExpandProperty Average)}},

 

 

    @{N=’Net(KBps)’;E={“{0:N2}” -f ($_.Group | where{$_.MetricId -eq ‘net.usage.average’} | Measure-Object -Property Value -Average | select -ExpandProperty Average)}},

 

 

    @{N=’Disk(KBps’;E={“{0:N2}” -f ($_.Group | where{$_.MetricId -eq ‘disk.usage.average’} | Measure-Object -Property Value -Average | select -ExpandProperty Average)}}

 

 

    $performance | Export-Csv D:scriptVMperf.csv

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.