Automation

 View Only
  • 1.  Question about getting Size of Virtual Machine

    Posted Nov 09, 2009 08:14 PM

    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?



  • 2.  RE: Question about getting Size of Virtual Machine

    Posted Nov 09, 2009 08:23 PM

    I suspect something went wrong with your submission.

    What "size" did you have in mind ? Size on disk, memory size...



  • 3.  RE: Question about getting Size of Virtual Machine

    Posted Nov 09, 2009 09:18 PM

    Size on disk.

    Tim



  • 4.  RE: Question about getting Size of Virtual Machine

    Posted Nov 11, 2009 05:51 PM

    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)

    http://tech.zsoldier.com