VMware Cloud Community
mrstorey303
Enthusiast
Enthusiast

Clone VM Between vCenters using New-VM

Not sure why this should be so difficult - cloning a VM between two vcenters in enhanced linked mode / same SSO domain using new-vm.

$mastervm = ‘vmtoclone’

$sourcevcenter = ‘sourcevcenter’

$destvcenter = ‘destinationvcenter’

$destdatastore = ‘destinationdatastore’

$destcluster = ‘destinationcluster’

$destfolder = ‘destinationfolder’

connect-viserver $sourcevcenter -Credential $cred

connect-viserver $destvcenter -Credential $cred

New-VM -server $destvcenter -name clonedvm -vm (get-vm -Name $mastervm -Server $sourcevcenter) `

-datastore (get-datastore -Server $destvcenter -Name $destdatastore) `

-location (get-folder $destfolder -Type vm -server $destvcenter) `

-DiskStorageFormat Thin -ResourcePool (get-cluster -Name $destcluster -server $destvcenter)

New-VM  -  The object <vim.ClusterComputeResource> has already been deleted or has not been completely created

I'm connected to both vcenters, and I'm able to create a new VM on the desired destination cluster, folder and datastore without cloning, but whenever I try to clone (by specifying the -vm parameter) it fails with the above error.

Any ideas?

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

Did you use the FQDN for both vCenters when connecting?

Did you check William's post Cross vCenter Server operations (clone / migrate) between versions of vSphere 6.x, to check if you have supported versions on both sides?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
mrstorey303
Enthusiast
Enthusiast

Hey,

Thanks for your quick reply -

Yes, the source and dest vcenter variables contain the vcenter fqdns as strings.

The whole environment is vSphere 6.5, and I'm doing a cold clone - I guess the slightly contentious thing is that the source VM is connected to a VDS (and needs to be connected to an identically named VDS port group at the destination).

The error doesn't suggest it's having an issue with the networking though - more the destination cluster object 'vim.ClusterComputeResource:domain-c7'.  The object I'm passing into the resourcepool parameter via (get-cluster) is definitely valid though.

Puzzled....

Reply
0 Kudos
watchrebel
Contributor
Contributor

I just came across this same behavior as well with PowerCLI 6.5.2.  Trying to cold clone a VM from one vCenter 6.0u3 instance to another 6.0U3 instance in the same SSO domain, with established admin connections to both vCenters.

The error I'm seeing is the same:

New-VM : 8/17/2017 3:06:16 PM   New-VM          The object has already been deleted or has not been completely created

    + CategoryInfo          : NotSpecified: (:) [New-VM], ManagedObjectNotFound

    + FullyQualifiedErrorId : Client20_QueryServiceImpl_RetrievePropertiesEx_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

Like yours, the source VM was also attached to a distributed portgroup.  I attached mine to a VSS portgroup just to test and get the same error.  It all works fine from the web client. 

Perhaps New-VM just doesn't support cross-vCenter actions yet?  I believe Move-VM just recently had the support added.

It's not a very clean workaround, but you could clone it within the same vCenter and then do a Move-VM after the fact.  Or if you're comfortable with using the API directly you could probably get around it that way.