VMware Cloud Community
ccnk
Contributor
Contributor
Jump to solution

Can we move-vm to more than one NIC properly

Hi ,

I have a requirement to move VMs from one esxi to other esxi with Move-VM but unable to figure out if we have more NICs on VM like  3 , 4 , 5 ,6 NICs , is it possible to move to right adapter to right port group. below is the script in my mind kindly help.

$networkAdapter = Get-NetworkAdapter -vm VMname
if ($networkAdapter.Count -ge 1) {

foreach ( $nadapter in $networkAdapter) {

$destinationPortGroup = Get-VDPortgroup -VDSwitch 'NewvDS' -Name "$($nadapter.NetworkName)-new"
Move-VM -VM VMname -Destination Esxiserver -NetworkAdapter $nadapter -PortGroup $destinationPortGroup -WhatIf

}

}

 

 

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could try something like this

$vNic = Get-NetworkAdapter -VM VMname
$pg = $vNic | %{Get-VirtualPortGroup -Name "$($_.NetworkName)-new"}

Move-VM -VM VMName -Destination Esxiserver -NetworkAdapter $vNic -PortGroup $pg


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

The Move-VM cmdlet parameters NetworkAdapter and Portgroup both accept an array of values.
That allows you to specify per vNIC to which destination portgroup they shall be moved.


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

Reply
0 Kudos
ccnk
Contributor
Contributor
Jump to solution

Could you please help with sample code to test from my end. Thank you in advance.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could try something like this

$vNic = Get-NetworkAdapter -VM VMname
$pg = $vNic | %{Get-VirtualPortGroup -Name "$($_.NetworkName)-new"}

Move-VM -VM VMName -Destination Esxiserver -NetworkAdapter $vNic -PortGroup $pg


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

Reply
0 Kudos