The provider in the current VITK release is rather limited in it's implemented features.
So I'm afraid you can't use that path.
The CopyVirtualDisk_Task method is still experimental and only works on ESX 3.5 but at least it allows you to do what you envisage.
Note1: the VirtualDiskManager is only available when you connect to an ESX server, not when you are connected to the VC.
Note2: although the method has a source and destination datacenter parameter this is not possible with this version since an ESX can only belong to 1 datacenter
Note3: you will need to choose the adapter type and the disk type of the destination vmdk
The following script copies the disk from a snapshot to another VMFS datastore.
$vm = <VM-name>
$hostname = (Get-VM $vm).host.name
# Connect to the ESX server
Connect-VIServer -Server $hostname
$vdiskMgr = Get-View (Get-View ServiceInstance).Content.VirtualDiskManager
$sourceDS = (Get-VM $vm | Get-Snapshot | Get-HardDisk).Filename
$sourceDC = (Get-View -Id (Get-VM $vm | Get-Datacenter).Id).MoRef
$destDS = <datastore-path-to-target-vmdk-file>
$destDC = $sourceDC
$destSpec = New-Object VMware.Vim.VirtualDiskSpec
$destSpec.adapterType = "lsiLogic"
$destSpec.diskType = "thin"
$force = $false
$taskMoRef = $vdiskMgr.CopyVirtualDisk_Task($sourceDS, $sourceDC, $destDS, $destDC, $destSpec, $force)
$task = Get-View $taskMoRef
while ($task.Info.State -eq "running" -or $task.Info.State -eq "queued") {
sleep 2
$task = Get-View $taskMoRef
}
- The script assumes there is only 1 snapshot for the VM but you can easily select the intended snapshot when there are more present (use for example the Where-Object)
- The destination of the copy has to be entered in the datastore path syntax. Something like this "\[<ds-name>\] <folder-name>/<vmdk-name>" (do not forget the blank after the closing square bracket !)
- The loop that waits for the completion of the copy task includes a "sleep 2" command. This to avoid additional load on the CPU(s)
- A copy of a VMDK can take some time (depending on the size). Feel free to add a progress-bar or any other indicator that the script is actually running.