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?
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
Yes, tried that as well, but giving error. I suppose it is expecting a distributed switch, not a standard switch.
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.
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.
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
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.