VMware

This Question is Answered

2 "helpful" answers available (6 pts)
6 Replies Last post: Dec 8, 2009 10:53 AM by LucD  

How to determine if a disk is Thin posted: Jan 30, 2009 2:08 AM

Click to view utarion's profile Novice 10 posts since
Dec 15, 2008

I have a quick query. I am trying to determine using Powershell if a Disk is thin provisioned or not. Is there a way programmatically to determine this? I was using the following but it does not provide me with what I want.

$fileQueryFlags = New-Object VMware.Vim.FileQueryFlags
$fileQueryFlags.FileType = $true
$fileQueryFlags.FileSize = $true
$fileQueryFlags.Modification = $true

Thanks


Re: How to determine if a disk is Thin

1. Jan 30, 2009 2:35 AM in response to: utarion
Click to view LucD's profile Champion vExpert 3,017 posts since
Oct 31, 2005
That info is available in the VirtualDiskFlatVer2BackingInfo object in the thinProvisioned property.
The following script scans through all your VMs and all their devices and will list any thin provisioned disks.
{noformat}
Get-VM | Get-View | % {
	Write-Host $_.Name
	foreach($dev in $vm.config.hardware.Device){
		if($dev.GetType().Name -eq "VirtualDisk"){
			if($dev.Backing.ThinProvisioned){
				Write-Host "`t" $dev.DeviceInfo.Label "ThinProvisioned"
			} 
		}
	}
}
{noformat}

Re: How to determine if a disk is Thin

3. Dec 7, 2009 11:59 AM in response to: LucD
Click to view sdog's profile Enthusiast 38 posts since
Jul 11, 2007
I get this error.

You cannot call a method on a null-valued expression.
At C:\thin_query.ps1:4 char:18
+ if($dev.GetType <<<< ().Name -eq "VirtualDisk"){

I have vCenter Server 4.0 update 1.

Any suggestions?

Regards

Re: How to determine if a disk is Thin

4. Dec 8, 2009 3:03 AM in response to: sdog
Click to view tonygent's profile Enthusiast 43 posts since
May 30, 2006
Looks like a Cut and Paste issue :o)

try replacing the $vm with $_ as below :
Write-Host $_.Name
foreach($dev in $_.config.hardware.Device)

Let me know if this works for you :)

TG

Re: How to determine if a disk is Thin

5. Dec 8, 2009 10:50 AM in response to: utarion
Click to view c_shanklin's profile Master VMware Employees 852 posts since
Dec 3, 2007
Actually I believe that starting with PowerCLI 4.0 U1 Get-HardDisk will tell you if a disk is thin or not. I'm away from my lab at the moment so I can't confirm but I'm pretty sure we made this change.

=====
Carter Shanklin
Read the PowerCLI Blog
Follow me on Twitter

Re: How to determine if a disk is Thin

6. Dec 8, 2009 10:53 AM in response to: c_shanklin
Click to view LucD's profile Champion vExpert 3,017 posts since
Oct 31, 2005
Confirmed, the StorageFormat property will tell you what kind of disk it is.

VMware Beta Programs

Want to be Considered for Future Beta Programs?

Learn More

VMware Developer

Download SDKs, APIs, videos,
training, and more in the Developer community.

Learn More

Developer
Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld
Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

Only VMware ... Delivers Nexus 1000V

Ensure consistent, policy-based network capabilities to virtual machines across your data center.

Learn More

Communities