Unfortunately in VCenter 5.1 there is no way to move a hard drive attached to a vm from thick provisioned to thin. The hack right now is to move drive into a different datastore, and while moving it change its hard drive type value.
first a quick way to list all the servers you have that are thin-provisioned.
or export them
or filter them, to solely capture the servers that aren't thin provisioned
we have a vm1, we are trying to move it's hard-drive
as you can see 'vm1' is in my 'vmfs02' datastore, therefore will move it to my vmfs_03 data store and in the process make it thin.
warning -Confirm:$false will move without asking you to confirm
The code below isn't the best solution, but for now it does the work. I know I have 4 datastores, and if server isn't one, must be in another. Later when my stores grow I'll have more targetted rules, like preserving affinity rules
Code does not work for all cases, read below
It is good to learn from one's mistake.
The code above doesn't always work for a simple reason,
When a hard disk is directly retrieved from a datastore there isn't enough information to determine whether it's attached to a VM or not. there needs to be a direct retrieval of the disks from the VMs to fully support moving a vm.
Also while digging further, I've found a new way to select vms and their drives.
this allows me to select disk direcly. `RunAsync` watch out for this flag, it will perform task in background and asynchronously.
`Import-Csv C:\ConvertThem3.csv` as you can see I import the vms from a spreadsheet. all that spreadsheet has is a field called Name and below vms.