VMware Cloud Community
ae_jenkins
Enthusiast
Enthusiast
Jump to solution

Thin Provisioned Disks

So, I'm pretty good with PowerCLI, but really bad with API calls . . . here goes my question.

The "get-harddisk" cmdlet in v4 of course has the "StorageFormat" property, identifying if the HD is thin or thick. Is there a way (API or otherwise) to pull in both the "defined" vHD size and the actual vHD size? For example, if I give a VM a 40 GB vHD, this is the "defined" size. If I only put 1 GB of data on the vHD, the "actual" size would be roughly 1 GB. I'm looking for that difference (39 GB).

Any ideas? I'm looking at you LucD Smiley Wink

Thanks

Alan

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Fyi, I expanded on the script below in yadr – A vdisk reporter.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this, it's not to most elegant solution I admit.

$vmName = <vm-name>

$vm = Get-VM $vmName | Get-View
$vm.Config.Hardware.Device | where {$_.DeviceInfo.Label -like "Hard disk *"} | %{
	$hd = $_
	$hdKey = $hd.Key
	$vm.LayoutEx.Disk | where {$_.Key -eq $hdKey} | %{
		$files = $_.Chain | %{$_.FileKey} | %{$_}
	}
	$allocated = 0
	$vm.LayoutEx.File | where {$files -contains $_.Key} | %{
		$allocated += $_.Size
	}
	Write-Host $hd.DeviceInfo.Label $hd.CapacityInKB ($allocated/1KB)
}

The sizes are displayed in KB.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

LucD
Leadership
Leadership
Jump to solution

Fyi, I expanded on the script below in yadr – A vdisk reporter.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ae_jenkins
Enthusiast
Enthusiast
Jump to solution

Hi LucD

Wow - thanks so much for all this information - I have been pulled away from this task temporarily, but with all the work you put into this I'm sure it's either totally correct or will send me in the right direction. Points to you sir.

0 Kudos