Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 49146

Re: PowerCLI VM Disk Usage

$
0
0

Hi All,

 

I have tried to pull the report however I cannot find the disk free space or disk free space percent correctly pulling the information.

Can someone help on this.

 

foreach($vm in Get-VM){

   Get-HardDisk -VM $vm | ForEach-Object {

   $HardDisk = $_

   $row = "" | Select Hostname, Cluster, VM, GuestName, Datastore, VMXpath, HardDisk, DiskType, CapacityGB, DiskFreespace, TotalVMFSConsumed, ProvisionType

   $row.Hostname = $vm.VMHost.Name

   $row.Cluster = (Get-Cluster -VM $vm ).Name

   $row.VM = $VM.Name

   $row.GuestName = $vm.Guest.HostName

   $row.Datastore = $HardDisk.Filename.Split("]")[0].TrimStart("[")

   $row.VMXpath = $HardDisk.FileName

   $row.HardDisk = $HardDisk.Name

   $row.CapacityGB = ("{0:f1}" -f ($HardDisk.CapacityKB/1MB))

   $row.DiskFreespace = $vm.Guest.Disks | Measure-Object FreeSpaceGB -Sum | Select -ExpandProperty Sum

   $row.DiskType = $HardDisk.get_DiskType()

   $row.TotalVMFSConsumed = $vm.get_UsedSpaceGB()

   $row.ProvisionType = $HardDisk.StorageFormat

   $report += $row

   }

}

 

Thanks

Krishna


Viewing all articles
Browse latest Browse all 49146

Trending Articles