VMware Cloud Community
benham
VMware Employee
VMware Employee

Set-NetworkAdapter bug?

Hi,

I am trying to use the set-networkadpater cmdlet to change the network portgroup of a VM from VDS to VSS, both portgroups have the same name.

E.g.

Type     SwitchName     PortgroupName

VSS      vSwitch0           VM Network

VDS      dvSwitch0         VM Network

Get-VM -name "test2vm" | Get-NetworkAdapter | Set-NetworkAdapter -networkname "VM Network"

Everything goes through successfully, but the connection default to the "VM Network" on the dvSwitch0. Is this a bug?

Or did I miss anything here?

0 Kudos
6 Replies
LucD
Leadership
Leadership

Did you try adding the DistributedSwitch parameter ?

Something like this

Get-VM -name "test2vm" | Get-NetworkAdapter | Set-NetworkAdapter -networkname "VM Network" -DistributedSwitch VDS


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

0 Kudos
benham
VMware Employee
VMware Employee

Yes, tried that as well, but giving error. I suppose it is expecting a distributed switch, not a standard switch.

0 Kudos
RvdNieuwendijk
Leadership
Leadership

You can try to temporarily rename to portgroup name on the standard switch to a unique name. Then change the networkadapter. And finally rename the portgroup name back to its original name.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
benham
VMware Employee
VMware Employee

That sounds like a good workaround. However, I think fundamentally there is some issue with the cmdlet. It would be good if it can take in a portgroup as an object, rather than a string name.

0 Kudos
LucD
Leadership
Leadership

Agreed on that.

You can also try my function from dvSwitch scripting – Part 8 – Get and Set network adapters


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

0 Kudos
benham
VMware Employee
VMware Employee

Thank LucD, great stuff on your blog.

I have tried it, the behaviour I am seeing is that when the same portgroup name is found on VDS and VSS, no changes is made on the VM portgroup connection.

0 Kudos