A few days ago I received a comment on This Post requesting a custom script to take a list of VMs from a file and convert them to thick. I quickly slapped something together and sent it to him for testing.

**REMEMBER** When converting thin to thick (or vice versa), you have to actually migrate the VM to a different datastore.

I’m posting this because it can be coupled with another post I have about Exporting VMs with Thin Disks to a CSV file, which would work perfectly for this. Run this one first to get a CSV with all your thin provisioned VMs.

In the Export Thin script, you will need to change the VM header in the CSV file to Name, since that’s what the migrate script looks for (or change the migrate script, up to you), add in a Destination header for the destination datastore in the CSV file after it’s exported. You could then plan it all out so your VMs are moved to specific datastores.

Here’s the migrate script:

param([string]$VMCSV,[string]$vCenter)
if(-not($VMCSV)){ Throw "You must supply the full path to your .csv file using -VMCSV"}
if(-not($vCenter)){ Throw "You must supply the vCenter to connect to using -vCenter"}
 
Add-PSSnapin VMware.* -erroraction silentlycontinue
 
$VMList = import-csv $VMCSV
 
Connect-VIServer $vCenter
 
Foreach ($VMServer in $VMList){
	$souce = get-vm $VMserver.Name | get-datastore
	write-host "#######################"
	Get-Date -format G
	write-host `t "Moving VM:" $VMServer.Name
	if($source -is [system.array]){foreach ($sourceDS in $source){write-host `t "Source Datastore: " $sourceDS.Name}}
	Else{write-host `t "Source Datastore: " $source.name}
	write-host `t "Destination Datastore: " $VMServer.Destination
	Move-VM $VMServer.Name -Datastore $VMServer.Destination -DiskStorageFormat thick > $null
	write-host `t "Completed:" $VMServer.Name
	Get-Date -format G
	write-host "#######################"
}
 
Disconnect-VIServer -confirm:$false

The output will look like this:
#######################
8/12/2013 4:15:59 PM
Moving VM: VM1
Source Datastore: Datastore1
Source Datastore: Datastore2
Destination Datastore: NewDatastore
Completed: VM1
8/12/2013 4:16:03 PM
#######################
#######################
8/12/2013 4:16:03 PM
Moving VM: VM2
Source Datastore: Datastore1
Destination Datastore: NewDatastore
Completed: VM2
8/12/2013 4:16:08 PM
#######################
#######################
8/12/2013 4:16:09 PM
Moving VM: VM3
Source Datastore: Datastore2
Destination Datastore: NewDatastore
Completed: VM3
8/12/2013 4:16:13 PM
#######################

I just wanted to share some collaboration stuff and show a combination of scripts to get the job done. You could even take it a step farther and have the Thin Disk CSV file contain provisioned space, include ramdisk size & overhead, then provide a desired destination datastore usage (say 85%), then have the script automatically move stuff around to fit on a list of provided destination datastores.

Hmm….maybe in another post :)