VMware Workspace ONE Community
Ethan_Liang
VMware Employee
VMware Employee

Got error when using powercli move mutli nic vm to other cluster

Hi  all:

     Please give some help .I work for a big customer to move over 2000 vms from old cluster to new cluster,most vms has 2 nic and more , I had tried this script https://blogs.vmware.com/PowerCLI/2017/01/spotlight-move-vm-cmdlet.html  but I got error when I ran script , The error like this:

C:\Users\Administrator> Move-VM -VM $vm -Destination  $Destination_Host -Datastore $Destination_Datastore -NetworkAdapter $NetworkAdapters -PortGroup $Destination_pg  -Confirm:$false -RunAsync

Move-VM: Can not bind parameter "PortGroup". You can not convert the "172.16.120" value of the "System.String" type to the "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualPortGroupBase" type.

Position line: 1 character: 127

+ ... e -NetworkAdapter $NetworkAdapters -PortGroup $Destination_pg  -Confi ...

+                                                   ~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Move-VM],ParameterBindingException

    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

=====================================================================

script:

$vms = Import-Csv C:\mutilnic.csv

$vm = $vms.vm_name

$NetworkAdapters = Get-NetworkAdapter -VM $vms.vm_name

$Destination_pg = @()

$Destination_pg += $vms.d_nic_01

$Destination_pg += $vms.d_nic_02

$Destination_pg | ft -AutoSize

$Destination_Datastore = "LocalDisk-126"

$Destination_Host = "192.168.0.126"

Move-VM -VM $vm -Destination  $Destination_Host -Datastore $Destination_Datastore -NetworkAdapter $NetworkAdapters -PortGroup $Destination_pg  -Confirm:$false -RunAsync

=====================================================================

csv file as blow:

vm_name,d_nic_01,d_nic_02

Win2012-02,172.16.120,172.16.11

0 Kudos
0 Replies