ccnk
Contributor
Contributor

Can we move-vm to more than one NIC properly

Jump to solution

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

}

}

 

 

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
3 Replies
LucD
Leadership
Leadership

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

0 Kudos
ccnk
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos