Hello,
Obviously I can get it for the whole VM with get-vm, but I'd like to see it for each harddisk/vmdk. I've wandered through the get-harddisk and get-view data without any luck.
My purpose is to find VMs that would benefit from the thin provisioning reclamation process with sdelete by comparing free space that the OS reports to free space that VMware reports. (If the OS reports signicantly more free space than the VM then it's a candidate.) I could add up the disk info from OS side, but I'd like to exclude the C: drive from the calculations.
Thanks in advance,
-Chris
Yes, you can, provided you have the VMware Tools installed.
Then you can use the Guest.Disk property to get a view from within the guest OS.
Something like this
foreach($vm in Get-VM){ foreach($hd in $vm.Guest.Disks){ $hd | Select @{N="VM";E={$vm.Name}}, @{N="Path";E={$hd.Path}}, @{N="Capacity";E={$hd.Capacity}}, @{N="Free";E={$hd.FreeSpace}} } }
Note that you can't assume that a virtual disk (a .vmdk) corresponds with 1 partition in the guest OS.
There can be multiple partitions on a virtual harddisk.
To do the mapping between the virtual harddisk and the guest OS partitions, have a look at Arnim's script in Miscellaneous script - Get-VMDiskMapping.And there's an even better version in the book.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That appears to be getting me OS level info.
$> Get-WmiObject win32_volume -computername $comp | ? { ($_.DriveType -eq 3) -and ($_.DriveLetter) } | select Capacity,Freespace,DriveLetter | ft -a
Capacity Freespace DriveLetter
-------- --------- -----------
10725732352 4238184448 C:
42943528960 35126947840 😧
$> (get-vm $comp).guest.disks | ft -a
Capacity FreeSpace Path
-------- --------- ----
10725732352 4238209024 C:\
42943528960 35126947840 D:\
$> get-vm $comp | select ProvisionedSpaceGB,UsedSpaceGB | ft -a
ProvisionedSpaceGB UsedSpaceGB
------------------ -----------
52.00058 46.86289
To confirm I deleted some files, and the numbers from the first 2 commands changed as expected and the 3rd command did not change.
I'd like to get the VMware thin provisioning level of info for each of a VM's VMDK's. (We do make one VMDK per Windows disk/drive letter.) If I can't then I'll just add up the info from the OS level.
Thank you,
-Chris
Afaik the numbers for thin provisioning info are only kept per datastore, not per individual virtual disk.
Unless you have each virtual disk on a seperate datastore, you will not be able to tell which virtual disk uses what.
Note that to reclaim disk space from Thin Provisioned virtual disks, you will have to use the sdelete tool from Sysinternals.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great. As long as I know the data can't be had I can stop looking for it.
Thanks for your help.
-Chris