how do I modify this to get the total sum of all vmdk/VM?
Try changing that line into
$result.HardDiskCapacityGB = Get-HardDisk -VM $vm | Measure-Object -Property CapacityGB -Sum | select -ExpandProperty Sum
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference