I'm running this basic command but not getting what I need:
PowerCLI C:\> get-vm vmlax002 | select name, provisionedspacegb, usedspacegb
what i get is 100GB for both provisionedspacegb and usedspaceGB
However, inside the OS, Windows actually sees that although it is a 100GB virtual disk, there is still 50GB of free space.
The virtual machine is think provisioned.
How can I get just the used space as it is seen from the oS perspective?
Thanks!
Check if the harddisks on that VM are really Thin Provisioned
Get-VM vmlax002 | Get-HardDisk | Select Name,StorageFormat,CapacityGB
The UsedSpaceGB you are looking at is what vSphere sees.
For a Thick harddisks the ProvisionedSpaceGB and the UsedSpaceGB are the same.
vSphere has not clue how much space the partition in the guest OS is actually using.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Check if the harddisks on that VM are really Thin Provisioned
Get-VM vmlax002 | Get-HardDisk | Select Name,StorageFormat,CapacityGB
The UsedSpaceGB you are looking at is what vSphere sees.
For a Thick harddisks the ProvisionedSpaceGB and the UsedSpaceGB are the same.
vSphere has not clue how much space the partition in the guest OS is actually using.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks - much appreciated. What I need to do is figure out how much space would we used after I convert a bunch of VMs from thick to thin. I was hoping I could use "used space" to do this but I can't. Is there any other way you can think of to do this?
Thanks!
You can query inside the guest OS what is actually used on each harddisk.
Fro a Windows guest OS you could use something like this (through the Invoke-VMScript cmdlet).
Get-WmiObject win32_logicaldisk | select DeviceId,Size,FreeSpace
For a Linux guest OS, you might want to run a 'du' command.
The problem might be to map the guest OS partitions to the vSphere harddisks.
There have been some claims lately that there is such a method, but in my experience, these methods only work in specific situations.
And definitely not in all situations.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks again. In my case, it's OK if I can't map the individual guest partitions vmdks. My overall goal is to see the total used space for all guest partitions of a single thick-provisioned VM. Can this be done somehow by doing a get-vm and then getting guest.disks or .hardisk somehow?
Yes, you can.
Something like this for example
foreach($vm in Get-VM | Get-VMGuest){
$vm.Disks |
Select @{N='VM';E={$vm.VMName}},Path,CapacityGB,FreeSpaceGB
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference