I have been trying to add a portgroup to a VM via the PowerCLI.
The command I am using is
Get-VM -Name 1 | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName dvPortGroup3
and the error I get is as follows
Set-NetworkAdapter : 30/01/2013 10:48:22 Set-NetworkAdapter The specified DV portgroup 'dvPortGroup3' can not be used for vnic connection:
Invalid portgroup type.
I can add the portgroup to the VM via the VMware Client.
Any pointers?
Thanks in advance.
Jeremy
I think you are trying to add VM port group which is on vDS which required a portkey parameter
Check the below article which will help to find the free ports
http://www.lucd.info/2012/02/14/dvswitch-scripting-part-12-find-free-ports/
http://communities.vmware.com/message/1987845
Thanks for the quick reply.
I just updated the command to as follows
Get-VM -Name 1 | Get-NetworkAdapter | Set-NetworkAdapter -DistributedSwitch dvSwitch2 -PortKey 10
The bold parts at the updates to the original code.
after running this I get the following error
Set-NetworkAdapter : 30/01/2013 11:37:03 Set-NetworkAdapter The specified port '10' does not exists or it's not available for vnic connection.
I have uploaded a screenshot showing that the vDS and portgroup, portkey exists.
Thanks
Do you have the host where the VM is hosted, connected to the dvSwitch ?
In the "Connectee" column where you have "1", I see my connected ESXi
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If i go into the VMware Client and go to Home > Inventory > Networking then select the port group or vDS it shows the host is connected.
Jeremy
Strange, in my test environment I see this on the switch (after the connect of VM2 to port 10)
I used the same cmdlets as you.
Which versions (vSPhere & PowerCLI) are you using ?
I used vSphere 5.1, dvSwitch 5.1 and PowerCLI 5.1 for my test.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference