Hello all,
I am a newbie to using PowerCLI, and I have a new evaluation setup of vCenter and ESXi for testing the feasibility of using linked clones. I have tried running the following script to create a clone, but only get the text I have pasted below the result heading. It seems pretty basic, so not sure what is going wrong?
Cheers,
Mark.
SCRIPT;
$sourceVM = Get-VM "Test" | Get-View
$cloneName = "Testclone"
$cloneFolder = $sourceVM.parent
$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec
$cloneSpec.Snapshot = $sourceVM.Snapshot.CurrentSnapshot
$cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec
$cloneSpec.Location.DiskMoveType = [Vmware.Vim.VirtualMachineRelocateDiskMoveOptions]::createNewChildDiskBacking
$sourceVM.CloneVM_Task( $cloneFolder, $cloneName, $cloneSpec )
RESULT;
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> .\basicc
lonehino2.ps1
Type Value
---- -----
Task task-97
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>
In your script you use the CloneVM_Task() method that creates a vSphere task. The output of the script is the task created. You can use the CloneVM() method instead. The CloneVM() method works synchronously and returns after the clone is created.
If you keep the CloneVM_Task() method, you can use the Get-Task cmdlet to retrieve the status of the task. You can use the Wait-Task cmdlet to wait until the task is completed.
In your script you use the CloneVM_Task() method that creates a vSphere task. The output of the script is the task created. You can use the CloneVM() method instead. The CloneVM() method works synchronously and returns after the clone is created.
If you keep the CloneVM_Task() method, you can use the Get-Task cmdlet to retrieve the status of the task. You can use the Wait-Task cmdlet to wait until the task is completed.