Saturday, March 21, 2020

PS | How to change vNIC of all VMs inside a portgroup

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
  1. There are around 500 VMs and doing it manually is a headache. 
  2. 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

Sponsor

AD BANNER
Powered by Blogger.
The Magazine

Text Widget

Facebook

Extra Ads

AD BANNER

Welcome to my Notes!

Hello Folks, My name is Gautam Johar. Actively working on VMware Cloud and keen to learn new and latest cloud technologies in market. Love ...

Contact Form

Name

Email *

Message *

Followers



Labels

Translate

Breaking

Random Posts

Follow Us

On Linkedin

Recent Posts

Recent Comments

Header Ads

Popular Posts

Popular Posts

Recent Posts

Text Widget

Search This Blog

Copyright © test blog | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com