VMware Cloud Community
mazixo
Contributor
Contributor
Jump to solution

change vm vswitch by command line or...

hi

I have 16 vm whose NIC's are connected to a vSWITCH called "vsw01".now thay all shoud change to new vswich called "vsw02".

is there any way to do it fast for all them or maybe some command . ?!

Love,Life,Freedome is iranain's right Maziyar Khamenh
0 Kudos
1 Solution

Accepted Solutions
mvayser
Contributor
Contributor
Jump to solution

Mazixo,

If there are only 16 VMs that are connected to old portgroup, you can use the following PowerCLI command to move any VM that is connected to  it:

Get-VM | Get-NetworkAdapter | Where-Object {$_.NetworkName -eq "PortgroupOld" } | Set-NetworkAdapter -NetworkName "PortgroupNew" -Confirm:$False

If there are only specific VMs that you need to move, add their names into a text file with each VM on a separate line:

Get-Content c:\SomePath\MyVMs.txt | Foreach {Get-VM $_ | Get-NetworkAdapter | Where-Object {$_.NetworkName -eq "PortgroupOld" } | Set-NetworkAdapter -NetworkName "PortgroupNew" -Confirm:$False }

View solution in original post

0 Kudos
5 Replies
TomHowarth
Leadership
Leadership
Jump to solution

what version of ESX are you using?

Tom Howarth VCP / VCAP / vExpert
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
mazixo
Contributor
Contributor
Jump to solution

esxi5

Love,Life,Freedome is iranain's right Maziyar Khamenh
0 Kudos
TomHowarth
Leadership
Leadership
Jump to solution

read the following KB article

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100812...

Tom Howarth VCP / VCAP / vExpert
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
mvayser
Contributor
Contributor
Jump to solution

Mazixo,

If there are only 16 VMs that are connected to old portgroup, you can use the following PowerCLI command to move any VM that is connected to  it:

Get-VM | Get-NetworkAdapter | Where-Object {$_.NetworkName -eq "PortgroupOld" } | Set-NetworkAdapter -NetworkName "PortgroupNew" -Confirm:$False

If there are only specific VMs that you need to move, add their names into a text file with each VM on a separate line:

Get-Content c:\SomePath\MyVMs.txt | Foreach {Get-VM $_ | Get-NetworkAdapter | Where-Object {$_.NetworkName -eq "PortgroupOld" } | Set-NetworkAdapter -NetworkName "PortgroupNew" -Confirm:$False }

0 Kudos
mazixo
Contributor
Contributor
Jump to solution

thank you so much ! 😉

Love,Life,Freedome is iranain's right Maziyar Khamenh
0 Kudos