Open Powershell as admin
Get-VM | ForEach { $Vm = $_; $_.HardDrives } | ForEach {
$GetVhd = Get-VHD -Path $_.Path
[pscustomobject]@{
Vm = $Vm.Name
Name = $_.Name
Type = $GetVhd.VhdType
ProvisionedGB = ($GetVhd.Size / 1GB)
CommittedGB = ($GetVhd.FileSize / 1GB)
}
} | Export-Csv -Delimiter “;” -Path “C:\temp\VMVHDStorageUsedTotal.csv”
Creates CSV with data in one column, select column in excel, go to data tab, then text to columns > Delimiter > Semicolon
Excel file would look like this:
Vm | Name | Type | ProvisionedGB | CommittedGB |
GW1 | Hard Drive on IDE controller number 0 at location 0 | Dynamic | 60 | 45.12890625 |
GW2 | Hard Drive on SCSI controller number 0 at location 0 | Dynamic | 40 | 28.97265625 |