VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

CapacityGB shows blank

Hi,

I am unable to get CapacityGB as it shows blank output for CapacityGB

Script

$report = @()

$folder = "RND"

$allocated = "" | Select "Cluster","Folder Name","Resource_Info","CPU","Memory(GB)","Capacity(GB)","Total VM's","PoweredOn VM's","PoweredOff VM's"

$allocated.'Resource_Info' = 'Allocated'

$allocated.CPU = 651

$allocated.'Memory(GB)' = 1829

$allocated.'Capacity(GB)' = 19026

$report += $allocated

$report += Get-Folder $folder | Get-VM | Group-Object -Property {$_.Folder.Id} | Select @{N="Cluster";E={Get-Cluster -VM $_.Group}},

  @{N="Folder Name";E={$folder = $_.Group[0].Folder; $path = $folder.Name; $path}},

  @{N='Resource_Info';E={'Used'}},

  @{N="CPU";E={$_.Group | Measure-Object -Property NumCpu -Sum | Select -ExpandProperty Sum}},

  @{N="Memory(GB)";E={$_.Group | Measure-Object -Property MemoryGB -Sum | Select -ExpandProperty Sum}},

  @{N="Capacity(GB)";E={"{0:f1}" -f ($_.Group | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum)}},

  @{N="Total VM's";E={$_.Group.Count}},

  @{N="PoweredOn VM's";E={($_.Group | Where-Object {$_.PowerState -eq "PoweredOn"}).Count}},

  @{N="PoweredOff VM's";E={($_.Group | Where-Object {$_.PowerState -eq "PoweredOff"}).Count}}

  $available = "" | Select "Cluster","Folder Name","Resource_Info","CPU","Memory(GB)","Capacity(GB)","Total VM's","PoweredOn VM's","PoweredOff VM's"

  $available.'Resource_Info' = 'Available'

  $available.CPU = $report[0].CPU - ($report[1..($report.Count -1)].CPU | Measure-Object -Sum).Sum

  $available.'Memory(GB)' = $report[0].'Memory(GB)' - ($report[1..($report.Count -1)].'Memory(GB)' | Measure-Object -Sum).Sum

  $available.'Capacity(GB)' = $report[0].'Capacity(GB)' - ($report[1..($report.Count -1)].'Capacity(GB)' | Measure-Object -Sum).Sum

  $report += $available

  $report

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That line should be

  @{N="Capacity(GB)";E={"{0:f1}" -f ($_.Group | Get-HardDisk | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum)}},


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

That line should be

  @{N="Capacity(GB)";E={"{0:f1}" -f ($_.Group | Get-HardDisk | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum)}},


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much LucD. Smiley Happy

0 Kudos