I wanted to know how many disks in our environment are thin provisioned, so I wrote a quick function to export that list to a CSV file.

I have it pull the VM name, vmdk path & name, Size in GB, and if it’s Thin Provisioned (Boolean, which should always be true).

Just copy & paste this into a .ps1 file and run it (or download link at bottom). The initial instantiation of $vms takes a while, depending on the size of your environment, but the rest goes quickly. Make sure you’re connected to a host or vcenter before you run it, or you won’t get anything.

function find-thin{
    write-host -fore green `n "getting all VMs, this may take a while"
    $vms = get-vm |sort name | get-view
    Write-host -fore green `n "Starting Scan"
    $vmdks = @()
    foreach ($vm in $vms){
        foreach ($device in $vm.config.hardware.Device){
            if($device.GetType().Name -eq "VirtualDisk"){
                    $info = "" | Select VM, File, SizeInGB, Thin
                    $info.VM = $vm.name
                    $info.File = $device.backing.filename
                    $info.SizeInGB = $device.capacityinkb/1048576
                    $info.thin = $device.Backing.ThinProvisioned
                    $vmdks += $info
    write-host -fore green `n "finished searching all VMs" `n
    $vmdks | export-csv d:\thindisk.csv

To change where the file is saved, simply change the path in line 27 to the destination of your choice.

Download: find-thin.ps1