ganapa2000
Hot Shot
Hot Shot

How to get Used Harddisk space + RDM Space of a VM

Jump to solution

Hi All,

I would like to know, harddisk space used by VM both RDM + VMDK

I am getting the details using the below script,

Get-VM | Get-HardDisk |

Select @{N='VM Name';E={$_.Parent.Name}},

@{N="IP Address";E={@($_.Parent.guest.IPAddress[0])}},

@{N="VM PowerState";E={@($_.Parent.PowerState)}},

@{N="CPU Count";E={@($_.Parent.NumCPU)}},

@{N="MemoryInGB";E={@($_.Parent.MemoryGB)}},

@{N="Cluster";E={Get-Cluster -VM $_.Parent}},

@{N="ESX Host";E={Get-VMHost -VM $_.Parent}},

@{N="Folder";E={$_.Parent.Folder.Name}},

@{N='HD Capacity';E={$_.CapacityGB}},

@{N="Datastore";E={Get-Datastore -VM $_}},

I am looking for similar output as below

VM Name     IP Address     VM PowerState     CPU Count     MemoryinGB     Cluster     ESXHost     Folder     HD Capacity(VMDK+RDM)     Datastore

VM1             10.10.10.10     PoweredON          4                    8                       ABC      11.11.11.11   ABC         2048                                   Datastore 1

VM2          10.10.10.11   PoweredON        4                   8                    ABC      11.11.11.13   ABC         3096                                 Datastore 2
0 Kudos
1 Solution

Accepted Solutions
Craig_Baltzer
Expert
Expert

If you just want the configured disk size (i.e. not the amount actually used)

Get-VM  |

    Select @{N='VM Name';E={$_.Name}},

    @{N="IP Address";E={@($_.guest.IPAddress[0])}},

    @{N="VM PowerState";E={@($_.PowerState)}},

    @{N="CPU Count";E={@($_.NumCPU)}},

    @{N="MemoryInGB";E={@($_.MemoryGB)}},

    @{N="Cluster";E={Get-Cluster -VM $_}},

    @{N="ESX Host";E={Get-VMHost -VM $_}},

    @{N="Folder";E={$_.Folder.Name}},

    @{N='HD Capacity';E={[Math]::Round(((Get-HardDisk -VM $_ | Measure-Object -Property CapacityGB -Sum).Sum),2)}},

    @{N="Datastore";E={Get-Datastore -VM $_}}

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership

Have a look at yadr – A vdisk reporter


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot

Hi LucD,

Thanks for your reply. I want the total harddisk space used by a VM which included VMDK + RDM

But the above link splits the details, which I dont need.

Example :

VM1      800 GB

VM2      1300 GB

0 Kudos
Craig_Baltzer
Expert
Expert

If you just want the configured disk size (i.e. not the amount actually used)

Get-VM  |

    Select @{N='VM Name';E={$_.Name}},

    @{N="IP Address";E={@($_.guest.IPAddress[0])}},

    @{N="VM PowerState";E={@($_.PowerState)}},

    @{N="CPU Count";E={@($_.NumCPU)}},

    @{N="MemoryInGB";E={@($_.MemoryGB)}},

    @{N="Cluster";E={Get-Cluster -VM $_}},

    @{N="ESX Host";E={Get-VMHost -VM $_}},

    @{N="Folder";E={$_.Folder.Name}},

    @{N='HD Capacity';E={[Math]::Round(((Get-HardDisk -VM $_ | Measure-Object -Property CapacityGB -Sum).Sum),2)}},

    @{N="Datastore";E={Get-Datastore -VM $_}}

0 Kudos