Hello all, I have a problem that I am working
on. I need to get the size of a virtual machine that was created and space on the datastore. Is that possible via Power
Shell?
I suspect something went wrong with your submission.
What "size" did you have in mind ? Size on disk, memory size...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Size on disk.
Tim
The easy way is to use the GUI. To get hard disk sizes for your VM's:
(Get-VM VMName).Harddisks
This will list all disks associated with the VM. Add these numbers together with the amount of RAM you have allocated to the VM and you get how much space the VM is taking up on a datastore. Below shows how you can add it all together.
((Get-VM VMName).Harddisks | foreach {$_.CapacityKB / 1kb} | measure-object -sum).sum + (get-vm vmname).MemoryMB
More efficiently and faster would look like below:
$VMName = Get-VM VMName
($VMName.Harddisks | foreach {$_.CapacityKB / 1kb} | measure-object -sum).sum + $VMName.MemoryMB
K. Chris Nakagaki (Zsoldier)