I wrote this post a while back on how to use the API to convert VMs from thin to thick, which you could also go from thick to thin using it. I had written it because I was trying to use the inflate function, which isn’t allow against powered on VMs.

It was pointed out by a reader that I could have simply used Move-VM to accomplish the same task. This is great, shows how a second set of eyes and a different perspective can help you solve the problem. You could simply do

and it will move your VM to the specified datastore and convert to thick. You could use either thin or thick.

If you wanted to move every VM on a datastore, say Datastore1, to a new datastore, say Datastore2, and convert all of them to either thin or thick, you could do it like this:

You cannot specify the current datastore as the destination datastore, though. It will complete, but it will not convert your VM’s disk format, you have to actually Storage vMotion the VM to a different datastore. It basically validates the destination datastore is where it currently resides and exits without trying to convert your vmdk.

You could then take it a step farther and make a function that supports parameters, like if you wanted to move VMs on multiple datastores, or a given list of VMs to a specific datastore. For instance, you could create something like “convert-vms.ps1” and run it like this

and it would move all four VMs to datastore2 and convert them to thick in the process. Or something like

That would move all VMs from datastores 1 & 2 and thin provision them on datastore3.

If anyone’s interested in the actual script/function, let me know and I can put one together fairly quickly.