3 Replies Latest reply on Aug 10, 2011 10:06 AM by wamatha

    Total disk usage per vm

    wamatha Enthusiast

      I need help!


      I am looking for a script tht can generate a report on total disk used per VM, in GB

        • 1. Re: Total disk usage per vm
          mcowger Champion

          Something like this would be a good start:


          Get-VM | Get-HardDisk | Format-Table -GroupBy Parent


          Gives you the virtual hard disks per VM along with filename and capacity in KB.  You could use a calculated property to convert that to GB if needed.

          • 2. Re: Total disk usage per vm
            mattboren Master

            Hello, wamatha-


            mcowger definitely points you in the right direction with his post.  Another way, using Get-VM, is like:


            Get-VM | Select Name,UsedSpaceGB



            Or, if you want some speed on that script (like I do), you could use:


            Get-View -ViewType VirtualMachine -Property Name,Summary.Storage.Committed |
            Select Name,
            ="UsedSpaceGB"; e={[Math]::Round(($_.Summary.Storage.Committed / 1GB), 2)}}


            This should be far faster than the Get-VM route, especially as the VM count rises.  Note:  the second way includes templates, which could easily be filtered out if desired.

            • 3. Re: Total disk usage per vm
              wamatha Enthusiast

              works well, but for clustered vm's with RDM's it's total is wrong, instead of only showing say one vm with RDM totals, all other vm's in the cluster have their sum totals including the rdms as well