When using View Composer with vCenter, a task it listed under recent tasks called "Create Linked Clone". There must be some vCenter API command to do this. I'm trying to figure out if there's a manual way to run this Create Linked Clone method from a Powershell script. As far as I know, View Composer itself shouldn't be required to create a Linked Clone; from what I understand it uses its database and such to just keep track of replicas and linekd clones and such.
Does anyone know what the API command to run this is? Or does it just become this task if you pass a funky VirtualMachineCloneSpec?
As always you're awesome. Don't know why I didn't think to look at the Tke pack.
I still think there must be an API command for it, otherwise why would it show up correctly in the Recent Tasks list in the VI Client with a nice pretty name? It must have been added in Update 2 (since that was the requirement during the VDM3 beta) so it may not be in the Docs. I've snooped around the MOB and I can't find it either...
Guess I'll have to go install PowerShell 2.0 CTP3
The following PowerShell code uses the vSphere CloneVM API to create a linked clone from a source VM’s current snapshot point. The clone will be located on the same host, datastore, and folder as the source VM. It requires a snapshot to exist on the source VM, and it requires vCenter Server.
$sourceVM = Get-VM "source_vm_name" | Get-View
$cloneName = "linked_clone_name"
$cloneFolder = $sourceVM.parent
$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec
$cloneSpec.Snapshot = $sourceVM.Snapshot.CurrentSnapshot
$cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec
$cloneSpec.Location.DiskMoveType = "createNewChildDiskBacking"
$sourceVM.CloneVM_Task( $cloneFolder, $cloneName, $cloneSpec )
Note that DiskMoveType is not a string; it's of enumerated type VirtualMachineRelocateDiskMoveOptions.