VMware Cloud Community
fabio1975
Commander
Commander

Powercli cross vcenter migration

I am using the MOVE-VM command to perform automatic migrations of VMs from one vCenter to another. I have some VMs that have disks split across multiple datastores. How do I specify which target vCenter datastores to place my disks on?

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
11 Replies
LucD
Leadership
Leadership

With the cmdlet you can't specify that, you will have to use API method.


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

Reply
0 Kudos
d3m1g0d
Enthusiast
Enthusiast

Afaik you cannot do this with the Move-VM cmdlet. It only accepts a single datastore as destination.

You should be able to do it using the RelocateVM_Task of the VirtualMachine SDK object.

You would need to build a VMware.Vim.VirtualMachineRelocateSpec object for the virtual machines config files specifying the destination datastore MoRef. Then add a VMware.Vim.VirtualMachineRelocateSpecDiskLocator object for each VMDK specifying its DiskID and Datastore MoRef from the destination.

Reply
0 Kudos
fabio1975
Commander
Commander

Thanks LucD, 

do you have some example to use API method?

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

You can start with the xMove-VM.ps1 script.

You will have to adapt line 126 if the datastores on the target vCenter do not have the same names as the ones on the source vCenter.


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

Reply
0 Kudos
fabio1975
Commander
Commander

I tried to use the script (I changed some parameters), but the vm relocation failed with 

"Authenticity of the host's SSL certificate is not verified."

9/27/2023 10:14:46 PM Wait-Task The operation for the entity "MasterImagew11v2" failed with the following message: "Authenticity of the host's SSL certificate is not verified."

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

Did you set the InvalidCertificateAction to Ignore with the Set-PowerCliConfiguration cmdlet?


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

Reply
0 Kudos
fabio1975
Commander
Commander

I tried setting invalidCertificateAction to Ignore (I set it on the script), but the error persists

 

 

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

Did you do that for all Scopes?
And did you stop/start your PS session?


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

Reply
0 Kudos
fabio1975
Commander
Commander

Hi LucD,

This is my settings

fabio1975_1-1695881555101.png

The certificate error is shown when starting the relocation and I saw this error on vcenter event:

fabio1975_2-1695881682498.png

I'll give you two pieces of information: my goal is to move VMs from an infrastructure with vCenter 6.7 to one with vCenter 7u3. The two vCenters are not in Enhanced Linked Mode and see the same LUNs (my goal is to do a vMotion without interruption of service). From Web Gui everything works, the only problem is that I have to migrate hundreds of VMs.

 

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

There can be many possible causes, have a look at the options in Re: Authenticity of the host's ssl certificate is ... - VMware Technology Network VMTN


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

Reply
0 Kudos
baptiste91
Contributor
Contributor

Did you find a solution to the authenticity error?

Reply
0 Kudos