I have a script to identify the number of vHDD attached to a virtual machine and to determine its capapcity. Can anyone guide me with a script to determine the vHDD usage (For example if a VM is assigned with 50GB of vHDD how to determine its used space for all the VM's in a vCenter console)
$report = @()
foreach ($vm in Get-VM)
{
$row = "" | Select Name, HD1, HD2
$row.Name = $vm.Name
$row.HD1 = (Get-HardDisk -VM $vm -Name 'Hard disk 1' -ErrorAction SilentlyContinue).CapacityGB
$row.HD2 = (Get-HardDisk -VM $vm -Name 'Hard disk 2' -ErrorAction SilentlyContinue).CapacityGB
$report += $row
}
$report | Export-Csv ".\report.csv" -NoTypeInformation -UseCulture