Set-NetworkAdapter : 6/11/2012 12:51:47 PM Set-NetworkAdapter The specified port '1405' does not exists or it's not available for vnic connection.
I receive the above error message when trying to run:
Get-VM SOMEGUEST | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected $true -DistributedSwitch dvSwitch01 -PortKey 1405 -Confirm:$FALSE
I have confirmed portkey 1405 exists and that it is not in use. Please advise; thanks.
Also tried this method but get the same result: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Set-NetworkAdapter.html
$distributedSwitch = Get-VirtualSwitch -Distributed -Name DistributedSwitch Get-VM VM | Get-NetworkAdapter | Set-NetworkAdapter -PortKey 1405 -DistributedSwitch $distributedSwitch
Is the portkey in the portgroup that you use on the VM ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, the portkey is within the portgroup's range.
But anyways, how would the command even know which portgroup you wanted to use for the VM?
So the NIC is not connected to a portgroup ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Btw, did you check the free port with my Get-dvPgFreePort function ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The NIC is currently assinged to a distributed switch port group. I tried moving it to a standard switch portgroup but I receive the same error. The free portkey function looks useful, but for now I just want to get the first step completed. I have confirmed from vsphere client the portkey is free.
I noticed that when I show the properties of the port groups it shows "0" as the number of available ports; could that be the problem? The port groups are using the default settings (128 ports - static binding).
That depends on the type of port binding you are using for that portgroup.
If the binding is ephemeral, the number of ports is 0. And the portgroup allocates one port for each connected VM.
And it looks indeed as if Set-NetworkAdapter doesn't work with ephemeral ports.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
But as I mentioned the port groups are configured as static binding with the default number of ports, 128. They are not set to ephemeral. Not sure why the number of ports is showing as 0.
Just tried it from the vSphere client, and apparently it allows you to define a portgroup with 0 ports.
But when you assign that portgroup to a NIC in a VM you get error (which sounds logical to me).
I'm wondering why you would define a portgroup with 0 static ports ?
As a placeholder perhaps ?
Can't you assign ports to the portgroup ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
My portgroups have 128 ports (I used the default setting). For example one of my port groups shows 10 guests connected, link up state, and they have connectivity. And there are 118 unallocated ports in this portgroup. If I run get-virtualportgroup -name "myportgrp" it returns numports = 0; I'm not sure why this is the case, but I did not define it as 0.
A little off topic, but hoping it's related enough not to upset anyone..
how can you use the set-networkadapter cmdlet to work with a standard vswitch? Everything seems to be cusomized towards a vDS (makes sense usually, but this is a migration.. just need vswitches temporarly).
When I don't specifiy a switch, it seems to default to the 1000v.
thanks!
vDS has some customization because you must find a way to select a free port key (a method is not "built in") to use the main cmdlet.
To work with standard switches you just need to specify the network name (the required parameters for the cmdlet are different when working with vDS):
get-vm yourvm | | get-networkadapter | set-networkadapter -networkname yourstdprtgrp
I don't know why, but when I don't specify any switch, it operates on the 1000v. Perhaps because mgmt is in it too?
I've got a script working to change from the standard vswitch to the coresponding network in the 1000v working, but not the other way around.
Use the type switch; for example Set-NetworkAdapter -type e1000.
Does my function return any free ports on that port group ?
It looks as if the NumPorts property has a problem
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference