This was the requirement during a network migration from physical to NSX. You might know that changing the VM's network (from VLAN portgroup to VXLAN portgroup) is essential part of this migration. But the challenges are
$TPortgroup = Read-host "Enter the name of target Portgroup here "
foreach($VM in (Get-Content C:\temp\vmlist.txt)){Get-VM -Name $VM | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $TPortgroup
Above command will change all the NICs of this VM1. Solution is
Get-Cluster 'ClusterName' | Get-VM |Get-NetworkAdapter |Where {$_.NetworkName -eq 'Source PG Name' } |Set-NetworkAdapter -NetworkName 'vxw-dvs-48-universalwire-VXLAN PG Name' -Confirm:$false
Above command will target only those Network Adapter which belongs to 'Source PG Name' and will change the PG for on this network adapter. Any doubt? Feel free to comment.
Thank you,
Team vCloudNotes
- There are around 500 VMs and doing it manually is a headache.
- Many VMs have multiple NICs so we cannot simply give source of a VM and change the NIC. For example,
$TPortgroup = Read-host "Enter the name of target Portgroup here "
foreach($VM in (Get-Content C:\temp\vmlist.txt)){Get-VM -Name $VM | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $TPortgroup
Above command will change all the NICs of this VM1. Solution is
Get-Cluster 'ClusterName' | Get-VM |Get-NetworkAdapter |Where {$_.NetworkName -eq 'Source PG Name' } |Set-NetworkAdapter -NetworkName 'vxw-dvs-48-universalwire-VXLAN PG Name' -Confirm:$false
Above command will target only those Network Adapter which belongs to 'Source PG Name' and will change the PG for on this network adapter. Any doubt? Feel free to comment.
Thank you,
Team vCloudNotes
0 Comments:
Post a Comment